Книга: Standard Template Library Programmer
Разделы на этой странице:
Component type: function
template <class InputIterator, class OutputIterator, class T>
OutputIterator remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
Remove_copy copies elements that are not equal to value from the range [first, last) to a range beginning at result. The return value is the end of the resulting range. This operation is stable, meaning that the relative order of the elements that are copied is the same as in the range [first, last).
Defined in the standard header algorithm, and in the nonstandard backward-compatibility header algo.h.
Requirements on types
• InputIterator is a model of Input Iterator.
• OutputIterator is a model of Output Iterator.
• InputIterator's value type is convertible to a type in OutputIterator's set of value types.
• T is a model of Equality Comparable.
• Objects of type T can be compared for equality with objects of InputIterator's value type.
• [first, last) is a valid range.
• There is enough space in the output range to store the copied values. That is, if there are n elements in [first, last) that are not equal to value, then [result, result+n) is a valid range.
• result is not an iterator in the range [first, last) .
Linear. Exactly last – first comparisons for equality, and at most last – first assignments.
Print all nonzero elements of a vector on the standard output.
remove_copy(V.begin(), V.end(), ostream_iterator<int>(cout, "n"), 0);
copy, remove, remove_if, remove_copy_if, unique, unique_copy.