#include
#include
#include
using namespace std;
template
bool IsEven (const elementType& number)
{
return ((number % 2) == 0);
}
int main ()
{
vector v;
for (int nNum = -9; nNum < 10; ++ nNum)
v.push_back (nNum);
vector ::const_iterator i;
for ( i = v.begin (); i != v.end (); ++ i )
cout << *i << ' ';
cout << v.size () << "' elements" << endl;
// Use the count_if algorithm with the unary predicate IsEven:
size_t nNumEvenElements = count_if (v.begin (),v.end (), IsEven );
cout << "Number of even elements: " << nNumEvenElements << endl;
cout << "Number of odd elements: ";
cout << v.size () - nNumEvenElements << endl;
return 0;
}