stl::remove does NOT remove elements!

Mental note: stl::remove does NOT remove the elements in a collection. It merely moves the elements to the back of a collection and returns an iterator which points to the first element to be removed.

It can be used as follows:

#include 

// more stuff here..

myCollection.erase(
  std::remove(
    myCollection.begin(), 
    myCollection.end(), 
    myObj), 
  myCollection.end()
  );

Leave a Reply