P
Pallav singh
Q what are different scenario's under which a Container can ,
invalidate its iterator ?
invalidate its iterator ?
Different containers do it in different situations. One common for all
of them is when the element to which the iterator refers is erased.
std::list does not invalidate any other iterators when you erase the
element. std::vector can invalidate all iterators if it reallocates
memory (when it's growing). std::vector also invalidates all iterators
to elements following the erased one... What book on the Standard
library are you reading that doesn't explain all that?
V
Undefined Behavior
Undefined Behavior
Implementation-defined Behavior
Undefined Behavior
None of those have anything to do with invalidating iterators.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.