• The first form counts the elements in the range [beg,end) that are equal to value value.
• The second form counts the elements in the range [beg,end) for which the unary predicate
op(elem)
yields true.
• The type of the return value, difference_type, is the difference type of the iterator:
typename iterator_traits::difference_type
(Section 9.5, page 466, introduces iterator traits.)
• Note that op should not change its state during a function call. See Section 10.1.4, page 483, for
details.
• op should not modify the passed arguments.
• Associative and unordered containers provide a similar member function, count(), to count the
number of elements that have a certain value as key (see Section 8.3.3, page 404).
• Complexity: linear (numElems comparisons or calls of op(), respectively).
The following example counts elements according to various criteria