Topic: Iterator Safety for STL Lists
Author: Carley Williams <carley@heat.co.symbios.com>
Date: 1998/02/19 Raw View
Matt Austern <austern@sgi.com> writes:
> Matt Austern writes:
>
> Inserting an element into a list<> does not invalidate any iterators.
> Erasing an element from a list<> invalidates only iterators that point
> to the element being erased.
Would some give a reference paragraph where this "not invalidate"
behavior is defined in the standard? I'm having trouble finding it.
--------------------------------------------
Carley D. Williams
Symbios Logic
3351 Eastbrook Drive
Fort Collins, CO 80525
FAX: (970) 225-4829
PHONE: (970) 223-5100 x9421
EMAIL: Carley.Williams@symbios.com
--------------------------------------------
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Abhay Kanhere <abhay@hp11.cpdc.ece.nwu.edu>
Date: 1998/02/21 Raw View
Carley Williams <carley@heat.co.symbios.com> writes:
> > Inserting an element into a list<> does not invalidate any
iterators.
23.2.2.3 Note 1.
> > Erasing an element from a list<> invalidates only iterators that point
> > to the element being erased.
23.2.2.3 Note 3.
> Would some give a reference paragraph where this "not invalidate"
> behavior is defined in the standard? I'm having trouble finding it.
This information does not exist in lib.iterator section;
for each container, iterator validity is described along with
description of container's modifying member functions:
e.g. Section of C++ draft
23.2.2.3 (1) &
23.2.2.3 (3)
-- begin quote --
23.2.2.3 list modifiers [lib.list.modifiers]
"
iterator insert(iterator position, const T& x);
void insert(iterator position, size_type n, const T& x);
template <class InputIterator>
void insert(iterator position, InputIterator first,
InputIterator last);
void push_front(const T& x);
void push_back(const T& x);
1 Notes:
Does not affect the validity of iterators and references. If an
exception is thrown there are no effects.
...
iterator erase(iterator position);
iterator erase(iterator first, iterator last);
void pop_front();
void pop_back();
void clear();.
3 Effects:
Invalidates only the iterators and references to the erased ele-
ments.
-- end quote --
- Abhay
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: rblinne@newsguy.com (Rich Blinne)
Date: 1998/02/16 Raw View
Are then any known issues with respect to iterator safety where there are
insertions or deletions from a list? The obvious exception which I know
is dangerous is having an iterator pointing at a deleted element. Is
pointing to an adjacent element to a deleted element(s) a problem? Is
pointing to an adjacent element to an insertion point dangerous? Thank
you.
--
Rich Blinne
rblinne@newsguy.com
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Matt Austern <austern@sgi.com>
Date: 1998/02/17 Raw View
rblinne@newsguy.com (Rich Blinne) writes:
> Are then any known issues with respect to iterator safety where there are
> insertions or deletions from a list? The obvious exception which I know
> is dangerous is having an iterator pointing at a deleted element. Is
> pointing to an adjacent element to a deleted element(s) a problem? Is
> pointing to an adjacent element to an insertion point dangerous? Thank
> you.
Inserting an element into a list<> does not invalidate any iterators.
Erasing an element from a list<> invalidates only iterators that point
to the element being erased.
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]