title: How to remove elements from an std::set while iterating over it
body: <p>How can I remove elements from an <code>std::set</code> while iterating over it</p>
  
  <p>My first attempt looks like:</p>
  
  <pre><code>set&lt;T&gt; s;
  
  for(set&lt;T&gt;::iterator iter = s.begin(); iter != s.end(); ++iter) {
      //Do some stuff
      if(/*some condition*/)
          s.erase(iter--);
  }
  </code></pre>
  
  <p>But this is problematic if we want to remove the first element from the set because <code>iter--</code> invalidates the iterator.</p>
  
  <p>What's the standard way to do this?</p>