Share via


remove_copy

remove_copy

template<class InIt, class OutIt, class T>
    OutIt remove_copy(InIt first, InIt last, OutIt x, const T& val);

The template function effectively 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.

If x and first designate regions of storage, the range [x, x + (last - first)) must not overlap the range [first, last).

See the related sample program.