Topic: Invalidation of STL iterators
Author: Brian Parker <bparker@gil.com.au>
Date: 1997/03/01 Raw View
"John Aldridge" <jpsa@uk.gdscorp.com> wrote:
>I can't find anywhere in the latest draft which specifies which operations
>cause container iterators (or references to contained data) to become
>invalid.
>There are some specific comments in the sections on deque, list & vector,
>but I can't find anything more general.
>Specifically, do erase & insert operations on, say, a map cause iterators
>to the map to become invalid?
>Presumably the intent is that none of the const methods on a map will
>invalidate iterators, but does the standard say this?
You are right. This seems to be a bug in the draft standard. In the original
STL document (Feb, 1995) in the section on the requirements for associative
arrays (Page 23.6 [lib.associative.reqmts] Clause 6), it reads "iterator of
an associative container is of the bidirectional category. insert does not
affect the validity of iterators and references to the container, and erase
invalidates only the iterators and references to the erasesd elements.". The
current draft states only "iterator of an associative container is of the
bidirectional iterator category" and does not discuss insert or erase in the
specifications of the individual containers.
I think this should be submitted as an official comment to ensure it gets fixed.
,Brian Parker (bparker@gil.com.au)
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: "John Aldridge" <jpsa@uk.gdscorp.com>
Date: 1997/02/26 Raw View
I can't find anywhere in the latest draft which specifies which operations
cause container iterators (or references to contained data) to become
invalid.
There are some specific comments in the sections on deque, list & vector,
but I can't find anything more general.
Specifically, do erase & insert operations on, say, a map cause iterators
to the map to become invalid?
Presumably the intent is that none of the const methods on a map will
invalidate iterators, but does the standard say this?
Have I missed something obvious?
Cheers,
John Aldridge
jpsa@uk.gdscorp.com
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]