Can vector iterators in c++ be corrupted when you add elements?
This question already has an answer here:
Yes.
Adding elements to a vector can cause reallocation, which will invalidate all iterators and pointers to the vector elements.
Yes, this can happen. If the vector resizes old iterators are no longer valid. This is not true for all collections.
Take a look at the invalidation rules.
链接地址: http://www.djcxy.com/p/73336.html