I need to keep track of std::set element by saving the iterator returned by set.find().
My questions is does insertion and removing other elements invalidates the obtained iterator? From a simple test I did I can see it is not, but I’d like to ensure this feature is by design.
It never invalidates iterators or pointers/references to the elements. Only if you remove the element itself does the iterator or pointer/reference become invalid.
23.1.2/8: