Count occurrences of value in a range
This sample is licensed under the CC0 Public Domain Dedication.
Count the number of occurrences of a particular value in a range of elements.
On lines 9–11, we use the alrogithm
to count the occurrences of a particular value in the
For the first two arguments on lines 9–10, we use
std::end to get the begin and end
iterators for the range in which we wish to count. The third
argument on line 11 is the value to count the occurrences of.
To count elements according to a predicate, you can use