Standard C++ Library Class Reference

// A partition of the deque according to even/oddness.
//
partition(d2.begin(), d2.end(), is_even<int>());
//
// Output result of partition.
//
cout << "Partitioned values: " << "\t\t";
copy(d2.begin(), d2.end(), ostream_iterator<int>(cout," "));
cout << endl;
//
// A stable partition of the deque according to even/oddness.
//
stable_partition(d1.begin(), d1.end(), is_even<int>());
//
// Output result of partition.
//
cout << "Stable partitioned values: " << "\t";
copy(d1.begin(), d1.end(), ostream_iterator<int>(cout," "));
cout << endl;
return 0;
}
Output :
Unpartitioned values: 1 2 3 4 5 6 7 8 9 10
Partitioned values: 10 2 8 4 6 5 7 3 9 1
Stable partitioned values: 2 4 6 8 10 1 3 5 7 9
Warning
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you need to write :
deque<int, allocator>
instead of :
deque<int>
See Also
stable_partition