title: Erase/Remove contents from the map (or any other STL container) while iterating it
body: <p>Allegedly you cannot just erase/remove an element in a container while iterating as iterator becomes invalid. What are the (safe) ways to remove the elements that meet a certain condition? please only stl, no boost or tr1.</p>
  
  <p><strong>EDIT</strong>
  Is there a more elegant way if I want to erase a number of elements that meet a certain criteria, perhaps with  using  functor and for_each or erase algorithm ? </p>