Do STL iterators guarantee validity after collection was changed?
Depends on the container. e.g. if it’s a vector, after modifying the container all iterators can be invalidated. However, if it’s a list, the iterators irrelevant to the modified place will remain valid. A vector’s iterators are invalidated when its memory is reallocated. Additionally, inserting or deleting an element in the middle of a vector … Read more