Name
remove_copy function template — Copies elements that are not equal to a value
Synopsis
template<typename InIter, typename OutIter, typename T>
OutIter remove_copy(InIter first, InIter last, OutIter result, const T& value);The remove_copy function
template copies items from the range [first, last) to the range that starts at result. Only items that are not equal to
value are copied, that is, cases
in which operator== returns
false.
The return value is one past the end of the result range. The relative order of items that are not removed is stable.
The source and result ranges must not overlap. Figure 13-13 illustrates the removal process.
![]() |
Technical Notes
The remove_copy function
template assigns *(result +
n++) = *(first + m), in which n starts at 0, for all values of
m in [0, last - first), in which *(first + m) == value is false. The return value is
result + n.
Complexity is linear: exactly last - first comparisons are performed.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
