| Home | Libraries | People | FAQ | More

##### count_if

###### Prototype

    template<class SinglePassRange, class UnaryPredicate>
    typename range_difference<const SinglePassRange>::type
    count_if(const SinglePassRange& rng, UnaryPredicate pred);

###### Description

`count_if` returns the number of elements `x` in `rng` where `pred(x)` is `true`.

###### Definition

Defined in the header file `boost/range/algorithm/count_if.hpp`

###### Requirements

- `SinglePassRange` is a model of the Single Pass Range Concept.
- `UnaryPredicate` is a model of the `UnaryPredicateConcept`.
- `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`.
- The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.

###### Complexity

Linear. Exactly `distance(rng)` invocations of `pred`.