std::setの要素を追加・削除しても既存の要素への参照やイテレータは有効なまま維持される

N1905 23.1.2 - 8

The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements

C++の連想コンテナ全般(setとかmap系のコンテナ)でそうなる

当然、削除された要素自体への参照やイテレータは無効になる)