title: std::vector iterator invalidation
body: <p>There have been a few questions regarding this issue before; my understanding is that calling <code>std::vector::erase</code> will only invalidate iterators which are at a position <em>after</em> the erased element.  However, after erasing an element, is the iterator at that position still valid (provided, of course, that it doesn't point to <code>end()</code> after the erase)?</p>
  
  <p>My understanding of how a vector would be implemented seems to suggest that the iterator is definitely usable, but I'm not entirely sure if it could lead to undefined behavior.</p>
  
  <p>As an example of what I'm talking about, the following code removes all odd integers from a vector.  Does this code cause undefined behavior?</p>
  
  <pre><code>typedef std::vector&lt;int&gt; vectype;
  vectype vec;
  
  for (int i = 0; i &lt; 100; ++i) vec.push_back(i);
  
  vectype::iterator it = vec.begin();
  while (it != vec.end()) {
      if (*it % 2 == 1) vec.erase(it);
      else ++it;
  }
  </code></pre>
  
  <p>The code runs fine on my machine, but that doesn't convince me that it's valid.</p>