...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.57. Parameters
Parameter |
Requirement |
Description |
---|---|---|
|
A model of Forward
Sequence, |
The sequence to search |
|
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
comparisons.
result_of::size
<Sequence>::value
#include <boost/fusion/algorithm/query/count.hpp> #include <boost/fusion/include/count.hpp>
constvector
<double,int,int> vec(1.0,2,3); assert(count
(vec,2) == 1);