remove_if
remove_if
template<class FwdIt, class Pred>
FwdIt remove_if(FwdIt first, FwdIt last, Pred pr);
The template function effectively assigns first
to X
, then executes the statement:
if (!pr(*(first + N)))
*X++ = *(first + N);
once for each N
in the range [0, last - first)
. It then returns X
. Thus, the function removes from the sequence all elements for which the predicate pr(*(first + N))
is true, without altering the relative order of remaining elements, and returns the iterator value that designates the end of the revised sequence.
See the related sample program.