0

I know that the iterator of an element in vector may be changed, since the vector will double its size when there is no enough space.

So my question is that will the address of an inserted element in map change after other operations?

For example,

map<int, int> mp;
mp[0] = 1;
auto i = mp.find(0);
mp[1] = 2;
mp[2] = 3;
cout << it->second << endl;

will it->second always be 1 if I didn't change the value of mp[0] ?

Thanks.

arbuztw
  • 75
  • 2
  • 7

0 Answers0