C++ Standard Library remove_if() Sample

Description

remove_if() removes elements from a sequence in place, compacting the sequence as it goes. An iterator referencing the end of the compacted sequence is returned. A user-defined predicate is used to screen elements for removal.

Declaration

	template <class For, class Pred>
	    For remove_if(For, For, Pred);

Concept

The sample program sets up a vector of integers, and then removes the elements with value 5 from the vector. An iterator to the new end of the compacted vector is returned, and the values 1 3 1 are displayed. A predicate is defined using the Compare class operator().

Supported
Supported
Supported