...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Returns the number of elements of a given type within a sequence.
template< typename Sequence, typename T > typename result_of::count<Sequence, T>::type count( Sequence const& seq, T const& t);
Table 1.44. Parameters
Parameter |
Requirement |
Description |
---|---|---|
seq |
A model of Forward Sequence, e == t must be a valid expression, convertible to bool, for each element e in seq |
The sequence to search |
T |
Any type |
The type to count |
count(seq, t);
Return type: int
Semantics: Returns the number of elements of type T and equal to t in seq.
Linear. At most result_of::size<Sequence>::value comparisons.
#include <boost/fusion/algorithm/query/count.hpp> #include <boost/fusion/include/count.hpp>
const vector<double,int,int> vec(1.0,2,3); assert(count(vec,2) == 1);