Originally posted by: otherwise
"Given a reference to a stored object within a STL container, is it gaurenteed that said reference will be valid for the lifetime of the STL container?
Originally posted by: otherwise
Ok, ugh.
Do STL iterators have the same lifetime rules, or are these a bit smarter?
Originally posted by: IHateMyJob2004
stl .... should be call nstl
non standard template library.
I hate that thing.
Originally posted by: degibson
Originally posted by: IHateMyJob2004
stl .... should be call nstl
non standard template library.
I hate that thing.
I used to hate it, too. If you just come to realize that STL won't ever do exactly what you want it to do -- that STL only does what it wants to do, then you'll be OK. Programmers can adapt to anything.
Originally posted by: otherwise
Basically, does stl gaurentee that the Structure& reference will always be valid, or does stl internally copy around members under certain circumstances?
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.
insert does not affect the validity of iterators and references to the container, and erase invalidates only the iterators and references to the erased elements.