Name
remove_copy_if function template — Copies elements for which a predicate returns false
Synopsis
template<typename InIter, typename OutIter, typename Predicate>
OutIter remove_copy_if(InIter first, InIter last, OutIter result,
Predicate pred);The remove_copy_if function
template copies items from the range [first, last) to the range that starts at result. Only items for which pred returns false are copied.
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. See Figure 13-13 (under remove_copy) for an example of the removal
process.
Technical Notes
The remove_copy_if function
template assigns *(result +
n++) = *(first + m), in which n starts at 0, for all values of
m in [0, last - first), in which
pred(*(first + m)) 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