25 Algorithms library [algorithms]

25.3 Mutating sequence operations [alg.modifying.operations]

25.3.8 Remove [alg.remove]

template<class ForwardIterator, class T> ForwardIterator remove(ForwardIterator first, ForwardIterator last, const T& value); template<class ForwardIterator, class Predicate> ForwardIterator remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);

Requires: The type of *first shall satisfy the MoveAssignable requirements (Table [moveassignable]).

Effects: Eliminates all the elements referred to by iterator i in the range [first,last) for which the following corresponding conditions hold: *i == value, pred(*i) != false.

Returns: The end of the resulting range.

Remarks: Stable.

Complexity: Exactly last - first applications of the corresponding predicate.

Note: each element in the range [ret,last), where ret is the returned value, has a valid but unspecified state, because the algorithms can eliminate elements by swapping with or moving from elements that were originally in that range.

template<class InputIterator, class OutputIterator, class T> OutputIterator remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value); template<class InputIterator, class OutputIterator, class Predicate> OutputIterator remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);

Requires: The ranges [first,last) and [result,result + (last - first)) shall not overlap. The expression *result = *first shall ve valid.

Effects: Copies all the elements referred to by the iterator i in the range [first,last) for which the following corresponding conditions do not hold: *i == value, pred(*i) != false.

Returns: The end of the resulting range.

Complexity: Exactly last - first applications of the corresponding predicate.

Remarks: Stable.