title: how to remove all even integers from set<int> in c++
body: <p>I'm new to C++. I'd like to know how experienced coders do this.</p>
  
  <p>what I have:</p>
  
  <pre><code>set&lt;int&gt; s;
  s.insert(1);
  s.insert(2);
  s.insert(3);
  s.insert(4);
  s.insert(5);
  
  for(set&lt;int&gt;::iterator itr = s.begin(); itr != s.end(); ++itr){
  if (!(*itr % 2))
      s.erase(itr);
  }
  </code></pre>
  
  <p>and of course, it doesn't work. because itr is incremented after it is erased.
  does it mean Itr has to point to the begin of the set everytime after i erase the element from the set?</p>