Share via


remove

remove

template<class FwdIt, class T>
    FwdIt remove(FwdIt first, FwdIt last, const T& val);

The template function effectively assigns first to X, then executes the statement:

if (!(*(first + N) == val))
    *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 *(first + N) == val 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.