Le 21/12/10 01:17, Leigh Johnston a ?crit :
The fact that iterators are not invalidated for certain operations on
certain containers in the C++ standard library is an important and
useful property; I have code which relies on this and would feel very
uncomfortable trying to use a library which didn't support this.
There are too many rules to learn in the C++ model. Some containers
invalidate everything, others not, others in some operations, etc.
This promotes bugs, it is all too easy to forget some rule. Besides,
if you change the type of the container, the rules change and
previous code that worked stops working.
All this is just a too complex interface. So, I decided to make
a fresh start and a simple rule: do not modify the container
when you are iterating over it except by using the iterator
to delete the current item.
That is a simple interface. No exceptions, easy to learn and
use.
But that is also a design decision. I prefer simple interfaces
that are easy to use rather than complex interfaces that are error
prone. (In my opinion of course).
one can create bugs using any language feature.