C++ Standard Library count_if() Sample

Description

count_if() counts elements in a sequence, according to a user-defined predicate that specifies which elements should be included in the count.

Declaration

	template <class In, class Pred>
	    iterator_traits<In>::difference_type count_if(In, In, Pred);

Concept

The sample counts all the negative integers in the vector, displaying a value of 2. It declares a local variable of type iterator_traits<int*>::difference_type to capture the return value from count_if. This special type is used to portably handle varying size requirements on different platforms.

Supported
Supported
Supported