mmap iterator validity

M

Marco Cassiani

Hi,

if I insert an item in a mmap m:

mmap<Tkey, TObj> m;

mmap<Tkey, TObj>::iterator p1 = m.insert(make_pair(key, obj));

how long will be valid the p1 iterator if I made other insert and/or remove
operation after this insertion?

Marco
 
V

Victor Bazarov

Marco said:
if I insert an item in a mmap m:

mmap<Tkey, TObj> m;

mmap<Tkey, TObj>::iterator p1 = m.insert(make_pair(key, obj));

how long will be valid the p1 iterator if I made other insert and/or remove
operation after this insertion?

Iterators and references to elements of std::map are only invalidated
when the elements themselves are removed.

V
 

Ask a Question

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.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,291
Messages
2,571,453
Members
48,138
Latest member
DongGell95

Latest Threads

Top