count
template<
typename Sequence
, typename T
>
struct count
{
typedef unspecified type;
};
Returns the number of elements in a Sequence that are identical to T.
#include "boost/mpl/count_if.hpp"
| Parameter | Requirement | Description |
|---|---|---|
Sequence | A model of Forward Sequence | A sequence to be examined. |
T | A type | The type to be searched for. |
| Expression | Expression type | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
typedef count<Sequence,T>::type n; | A model of Integral Constant | Equivalent to typedef count_if< Sequence,is_same<_,T> >::type n; |
Linear. Exactly size<Sequence>::value comparisons for identity.
typedef list<int,char,long,short,char,short,double,long> types; typedef find<types, short>::type iter; BOOST_STATIC_ASSERT((is_same<iter::type,short>::type::value)); BOOST_STATIC_ASSERT((distance< begin<types>::type,iter >::type::value == 3));
Algorithms, count_if, find, find_if, contains