-4

Possible Duplicate:
Iterator invalidation rules

Imagine that I have a map<int, int>. Somehow I retrieved an iterator pointing to an entry pair<35,37> in the map. I save this iterator as map<int, int>::iterator _my_iterator3537.

After that, I did a lot of insertion to the map. Is _my_iterator3537 still pointing to the pair<35,37>?

Community
  • 1
  • 1
James Bond
  • 7,533
  • 19
  • 50
  • 64
  • 5
    You've been here for nigh on three years and asked 35 questions, yet people are still having to edit basic formatting into your posts. This is not good! Please do it yourself from now on! – Lightness Races in Orbit Nov 07 '12 at 21:02
  • To learn how @Lightness (and others) did that fancy formatting, click edit on one of your own posts after they edit it. – Yakk - Adam Nevraumont Nov 07 '12 at 21:08
  • Or click on the big `?` next to the box where you wrote your question to read the very thorough Stack Overflow formatting documentation. Capital letters isn't exactly "fancy". – Lightness Races in Orbit Nov 07 '12 at 21:09

1 Answers1

3

from documentation:

Map has the important property that inserting a new element into a map does not invalidate iterators that point to existing elements.

Erasing an element from a map also does not invalidate any iterators, except, of course, for iterators that actually point to the element that is being erased.

from standard: 23.1.2/8

The insert members shall not affect the validity of iterators and references to the container, and the erase members shall invalidate only iterators and references to the erased elements.

CyberGuy
  • 2,783
  • 1
  • 21
  • 31