Count

count (InputIterator first, InputIterator last, const T& value, Size& n) Function
count_if (InputIterator first, InputIterator last, Predicate pred, Size& n); Function

template 
void count(InputIterator first, InputIterator last, const T& value, Size& n);

template 
void count_if(InputIterator first, InputIterator last,
              Predicate pred, Size& n);

count adds to n the number of iterators i in the range [first, last) for which the following corresponding conditions hold: *i == value, pred(*i) == true. Exactly last - first applications of the corresponding predicate are done.

count must store the result into a reference argument instead of returning the result because the size type cannot be deduced from built-in iterator types such as int*.