A better approach is to use std::list on something you are doing a lot of inserts and erases on because they are O(n) with std::vectors and O(1) with lists. This of course assumes you are only needing iterative access (not random).

And if you insist on using a vector or need the random access, then just keep track of how far you are in the vector and get a new iterator.

[5] A vector's iterators are invalidated when its memory is reallocated.
Additionally, inserting or deleting an element in the middle of a vector invalidates
all iterators that point to elements following the insertion or deletion point. It
follows that you can prevent a vector's iterators from being invalidated if you use
reserve() to preallocate as much memory as the vector will ever use, and if all
insertions and deletions are at the vector's end.

That's from the SGI docs. So basically, if you keep an iterator one before the one you erase, and then increment it, it will be valid.