How long does the iterator returned by std :: set.find () last?

I need to track the std :: set element, while maintaining the iterator returned by set.find ().

My questions are: inserting and deleting other elements invalidates the resulting iterator? From a simple test, I realized that this is not so, but I would like this feature to be developed.

+7
c ++ set stl stdset
source share
1 answer

It never invalidates iterators or pointers / references to elements. Only if you delete the element itself, does the iterator or pointer / link become invalid.

23.1.2/8 :

Insertion elements should not affect the validity of iterators and references to the container, and erasure members invalidate only iterators and references to erased elements.

+11
source share

All Articles