User:Guildd
From cppreference.com
Iterator Invalidation
Category | Container | After insertion, are... | After erasure, are... | Conditionally | ||
---|---|---|---|---|---|---|
iterators valid? | references valid? | iterators valid? | references valid? | |||
Sequence containers | array | N/A | N/A | |||
vector | No | N/A | Insertion changed capacity | |||
Yes | Yes | Before modified element(s) | ||||
No | No | At or after modified element(s) | ||||
deque | No | Yes | No | Yes, except erased | Modified first or last element | |
No | No | Modified middle only | ||||
list | Yes | Yes, except erased element(s) | ||||
forward_list | Yes | Yes, except erased element(s) | ||||
Associative containers | set | Yes | Yes, except erased element(s) | |||
multiset | ||||||
map | ||||||
multimap | ||||||
Unordered associative containers | unordered_set | No | Yes | Yes, except erased element(s) | ||
unordered_multiset | ||||||
unordered_map | ||||||
unordered_multimap |