remove_if function template — Reorders a range to remove elements for which a predicate returns false
template<typename FwdIter, typename Predicate>
FwdIter remove_if(FwdIter first, FwdIter last, Predicate pred);
The remove_if
function
template "removes" items for which pred
returns false from the range
[first
, last
). The return value is one past the
new end of the range. The relative order of items that are not
removed is stable.
Nothing is actually erased from the underlying container;
instead, items to the right are assigned to new positions so they
overwrite the elements for which pred
returns false
. See Figure 13-13 (under remove_copy
) for an example of the removal
process.