On 19 Jun, 08:39, desktop <f...@sss.comwr ote:
Are there any case where iterators in a std::list gets invalidated
besides from the iterator pointing to an element thats deleted?
None other than members that erase elements
It seems that its only the std::vector that invalidates iterators
pointing to elements after a deleted element since its practically just
an array.
vector is not just an array
vector iterators are invalidated after erase, but only those
from the point of erase up. they are also invalidate after
insert, also from the point of insert up. In addition, if either
of the operations requires reallocation, all iterators are
invalidated.
this is similar or close for all containers with random access
iterators. At the moment they are deque, priority_queue,
vector and basic_string.
regards
DS