Erase–remove idiom
Motivation[edit]
A common programming task is to remove all elements that have a certain value or fulfill a certain criterion from a collection. In C++, this could be achieved using a hand-written loop. It is, however, preferred to use an algorithm from the C++ Standard Library for such tasks.[1][2][3]
The algorithm library provides the remove and remove_if algorithms for this. Because these algorithms operate on a range of elem