set::insert
results in no changes to iterator validity [cplusplus.com].
The common implementation of std::set
is red-black tree. Why are there no changes to iterator validity with reference to RB-tree insertion?
The way I understand RB-tree insertion is to first convert it to a 2,4-tree, do the insert and then convert back. However, from a previous question,
With the B-tree based implementation, due to node splits and consolidations, the erase member functions on these new structures may invalidate iterators to other elements in the tree