Prototypes:
#include <algorithm>
Forward_iterator remove_if (forward_iterator start, Forward_iterator end, predicate p);
The function remove_if () Removes all elements in the sequence [start, end] that are applied to the predicate p to return true.
This function returns a pointer to the last element iterator of the trimmed sequence.
Remember that remove_if () does not actually remove elements from the sequence [start, end]; If Remove_if () is applied on a container, the length of the container does not change (remove_if () is not possible to change the container's properties only through iterators), and all elements are still inside the container. As a practical practice, remove_if () moves all elements that should be removed to the end of the container and returns a delimited iterator. All of the removed elements can still be accessed through the returned iterator. In order to actually remove the element, you must call erase () on the container itself to erase the element that needs to be removed. This is also the origin of Erase-remove idiom name:
Container.erase (Remove_if (Container.begin (), Container.end (), pred), Container.end ());
remove_if () is similar to Partition (), but with a difference of two points: 1) They use the same predicate conditions exactly the opposite. 2) remove_if only emphasizes the previous part (the second part is no longer needed)
remove_if () runs at linear time (lineartimes).
REMOVE_IF () cannot be used for associative containers such as set<> or map<>.
Original address: http://huycwork.blog.163.com/blog/static/136751999201052044123998/
Std::remove_if