• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2    Copyright 2010 Neil Groves
3    Distributed under the Boost Software License, Version 1.0.
4    (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5/]
6[section:count_if count_if]
7
8[heading Prototype]
9
10``
11template<class SinglePassRange, class UnaryPredicate>
12typename range_difference<const SinglePassRange>::type
13count_if(const SinglePassRange& rng, UnaryPredicate pred);
14``
15
16[heading Description]
17
18`count_if` returns the number of elements `x` in `rng` where `pred(x)` is `true`.
19
20[heading Definition]
21
22Defined in the header file `boost/range/algorithm/count_if.hpp`
23
24[heading Requirements]
25
26* `SinglePassRange` is a model of the __single_pass_range__ Concept.
27* `UnaryPredicate` is a model of the `UnaryPredicateConcept`.
28* `SinglePassRange`'s value type is a model of the `EqualityComparableConcept`.
29* The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.
30
31[heading Complexity]
32
33Linear. Exactly `distance(rng)` invocations of `pred`.
34
35[endsect]
36
37
38