Topic: Destructive Iterators
Author: Eric D Crahen <crahen@acsu.buffalo.edu>
Date: 2000/03/02 Raw View
I have noticed that if you are iterating through a collection
and use the collections erase() method you invalidate the iterator
you are using ( assuming you are using a random-access one like
begin() returns) Is there an iterator implementation that allows
erase()ures and does not invalidate itself?
- Eric
---
[ 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: ashleyb@be.the.spam.invoke-llc.spam.com (Ash)
Date: 2000/03/03 Raw View
>I have noticed that if you are iterating through a collection
>and use the collections erase() method you invalidate the iterator
>you are using ( assuming you are using a random-access one like
>begin() returns) Is there an iterator implementation that allows
>erase()ures and does not invalidate itself?
No, but the non-associative containers return an iterator to the next
element in the sequence (or end(), if none).
---
[ 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 ]