title: Removing item from vector, while in C++11 range 'for' loop?
body: <p>I have a vector of IInventory*, and I am looping through the list using C++11 range for, to do stuff with each one.</p>
  
  <p>After doing some stuff with one, I may want to remove it from the list and delete the object. I know I can call <code>delete</code> on the pointer any time to clean it up, but what is the proper way to remove it from the vector, while in the range <code>for</code> loop? And if I remove it from the list will my loop be invalidated?</p>
  
  <pre><code>std::vector&lt;IInventory*&gt; inv;
  inv.push_back(new Foo());
  inv.push_back(new Bar());
  
  for (IInventory* index : inv)
  {
      // Do some stuff
      // OK, I decided I need to remove this object from 'inv'...
  }
  </code></pre>