Generally speaking is it a good idea to cache an end iterator (specifically STL containers) for efficiency and speed purposes? such as in the following bit of code:
Erasing from a container over which you are currently iterating is always a bad idea. The actual caching of your end iterator is not going to change that.