count_if()
Returns a count of the number of times the operator evaluated as true.
#include <algorithm> class Even { public: bool operator()( int val ){ return !( val%2 ); } }; ires = count_if( ia, ia+8, bind2nd(less<int>(),10) ); lres = count_if( ilist.begin(), ilist_end(), Even() );
Get Essential C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.