count

| Home | Libraries | People | FAQ | More

##### count

###### Description

Returns the number of elements of a given type within a sequence.

###### Synopsis

    template<
        typename Sequence,
        typename T
        >
    typename result_of::count<Sequence, T>::type count(
        Sequence const& seq, T const& t);

Table 1.54. 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

###### Expression Semantics

    count(seq, t);

Return type: `int`

Semantics: Returns the number of elements of type `T` and equal to `t` in `seq`.

###### Complexity

Linear. At most ``result_of::size`<Sequence>::value` comparisons.

###### Header

    #include <boost/fusion/algorithm/query/count.hpp>
    #include <boost/fusion/include/count.hpp>

###### Example

    const vector<double,int,int> vec(1.0,2,3);
    assert(count(vec,2) == 1);