#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
bool IsEven (const int& nNumber){
return ((nNumber % 2) == 0);
}
int main ()
{
vector <int> v;
for (int nNum = 0; nNum < 10; ++ nNum)
v.push_back (nNum);
vector <int> vecCopy (v);
// separate even values from the odd ones - even comes first.
partition (v.begin (), v.end (), IsEven);
for (size_t nItem = 0; nItem < v.size (); ++ nItem)
cout << v [nItem] << ' ';
return 0;
}
|