std::list

Started by
2 comments, last by quasar3d 20 years, 7 months ago
say I have a list, and I retrieve an iterator to an item in that list. after that I add some more items to the list. now is that iterator still valid? My Site
Advertisement
Hello quasar3d,

Technically no, but it could still be valid if you inserted at the end of the list.
If you were doing something with the list like process though it and then wanted to add sometime to it the insert return a iterator of new thin inserted and you can use that iterator as your new iterator.

Lord Bart
The iterator stays valid, Lord Bart is wrong.
See http://www.sgi.com/tech/stl/List.html
thanx. I already thought that it should be possible, because there''s no reason it couldn''t be possible for a linked list, since the memory location of the actual items doesn''t change, only the references to the next and previous items, but I didn''t know for sure if the stl implementation did guarantee that

btw. volkerg, do you know that your name is almost the same as the name of the most hated person in the netherlands

My Site

This topic is closed to new replies.

Advertisement