11 Algorithms library [algorithms]

11.3 Non-modifying sequence operations [alg.nonmodifying]

11.3.9 Count [alg.count]

template <InputIterator I, Sentinel<I> S, class T, class Proj = identity> requires IndirectRelation<equal_to<>, projected<I, Proj>, const T*> difference_type_t<I> count(I first, S last, const T& value, Proj proj = Proj{}); template <InputRange Rng, class T, class Proj = identity> requires IndirectRelation<equal_to<>, projected<iterator_t<Rng>, Proj>, const T*> difference_type_t<iterator_t<Rng>> count(Rng&& rng, const T& value, Proj proj = Proj{}); template <InputIterator I, Sentinel<I> S, class Proj = identity, IndirectUnaryPredicate<projected<I, Proj>> Pred> difference_type_t<I> count_if(I first, S last, Pred pred, Proj proj = Proj{}); template <InputRange Rng, class Proj = identity, IndirectUnaryPredicate<projected<iterator_t<Rng>, Proj>> Pred> difference_type_t<iterator_t<Rng>> count_if(Rng&& rng, Pred pred, Proj proj = Proj{});

Effects: Returns the number of iterators i in the range [first,last) for which the following corresponding conditions hold: invoke(proj, *i) == value, invoke(pred, invoke(proj, *i)) != false.

Complexity: Exactly last - first applications of the corresponding predicate and projection.