I have a problem wherein I'd like to remove some elements from a map. However, iterators to the map will be stored elsewhere, and I'd like to ensure that iterators to removed entries are not followed. They can either be deleted at the same time, or later. One option I thought of was to make the value type of the map a shared_ptr, and store equivalent weak_ptrs rather than iterators. However, that strikes me as a bit clumsy. Another option is to go hunt down all the iterators to elements that will be removed before removing them, but that's inelegant. I was wondering if anyone had an idea on how this task could be most gracefully accomplished.