...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Front Page / Algorithms / Querying Algorithms / count_if |
template< typename Sequence , typename Pred > struct count_if { typedef unspecified type; };
Returns the number of elements in Sequence that satisfy the predicate Pred.
#include <boost/mpl/count_if.hpp>
Parameter | Requirement | Description |
---|---|---|
Sequence | Forward Sequence | A sequence to be examined. |
Pred | Unary Lambda Expression | A count condition. |
For any Forward Sequence s and unary Lambda Expression pred:
typedef count_if::type n;
Return type: | |
---|---|
Semantics: | Equivalent to typedef lambda |
Linear. Exactly size::value applications of pred.
typedef vectortypes; BOOST_MPL_ASSERT_RELATION( (count_if< types, is_float<_> >::value), ==, 1 ); BOOST_MPL_ASSERT_RELATION( (count_if< types, is_same<_,char> >::value), ==, 2 ); BOOST_MPL_ASSERT_RELATION( (count_if< types, is_same<_,void> >::value), ==, 0 );