boost::mpl::count

# count

### Synopsis

    template<
          typename Sequence
        , typename T
        >
    struct count
    {
        typedef unspecified type;
    };

### Description

Returns the number of elements in a `Sequence` that are identical to `T`.

### Definition

    #include "boost/mpl/count.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | A model of Forward Sequence | A sequence to be examined.
`T` | A type | The type to be searched for.

### Expression semantics

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;` |

### Complexity

Linear. Exactly `size<Sequence>::value` comparisons for identity.

### Example

    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));

### See also

Algorithms, `count_if`, `find`, `find_if`, `contains`

Table of Contents
Last edited December 12, 2002 2:05 am