Name
count_if function template — Counts the number of times a predicate returns true
Synopsis
template<typename InIter, typename Predicate>
typename iterator_traits<InIter>::difference_type
count_if(InIter first, InIter last, Predicate pred);
The count_if
function
template returns the number of elements in the range [first
, last
) for which pred(*iter)
returns true.
Technical Notes
Complexity is linear: pred
is called exactly last -
first times.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.