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.
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.