Invalidation of STL Iterators - Effective STL Programming
Iterators are pointer-like objects that refer to elements maintained
in a container. In the STL, iterators are key abstractions on equal footing
with containers and algorithms. In fact, iterators are the glue between
them and need to be thoroughly understood by every STL user. In this
tutorial we look into one of the surprises related to use of iterators:
invalidation.
Depending on the type of the container, any operations performed on
the container might invalidate any iterators pointing to elements in the
container. These invalidation are in part expected, but sometimes they
come as a surprise. Ever too often, programmers overlook this side-effect
of iterator invalidation and as a result, have to cope with errors that
are hard to track down - pretty much like traditional pointer problems. |
|
PREREQUISITES
|
|
Level:
|
intermediate |
Duration:
|
90 minutes |
Prerequisites:
|
basic knowledge of C++ and the STL |
Presented at:
|
Software Development
,
San Jose, CA, April 2002
DevConnections
,
Orlando, FL, October 2002 |
If you are interested to hear more about this
and related topics you might want to check out the following seminar or
skim through some further reading:
|
Seminars
|
Paper
|
Slides
|
|