Re: vector.erase(iterator iter) will change "iter" or not?
On Feb 26, 11:31 am, Richard Herring <junk@[127.0.0.1]> wrote:
In message
<79bc8204-9fcd-4cae-808b-d6b179de1...@v3g2000hsc.googlegroups.com>,
James Kanze <james.ka...@gmail.com> writes
But physically it need not: see implementations where
vector<T>::iterator is implemented as plain T*.
It's not *required* by the STL. All of the good implementations
do it.
No doubt, if you define "good" implementations as the ones
that do it.
I define good by those which are standards conformant, and work
as advertised. Basically, Dinkumware and g++.
It's a shame they can't do the same for all the references and
pointers that also become invalidated.
That is, of course, a language issue, rather than a library
issue. The Boehm collector goes a long way in this regard, but
obviously, it can't help in cases where the memory is managed
elsewhere (e.g. in std::vector, but also things like pointers to
local variables).
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34