A
Alf P. Steinbach
* Kai-Uwe Bux:
Well, yeah, I wasn't precise either.
The case I was thinking of was creating objects by inserting them in a
list, and using pointers to those objects elsewere.
That is very risky when using a vector, because inserting a new object
may invalidate existing pointers. With a list all you have to remember
is to not destroy any list elements. Until pointer no longer used.
Cheers,
- Alf
Right, I was not precise. The actual objects in a vector might undergo
copy-destroy cycles. However, the _values_ are not vanishing from the
sequence unless you erase them. I have a tendency to consider the
copy-destruction way of moving around objects that happens when a vector
reallocates an artifact that does not affect identity of objects on a
conceptual level. However, since the standard defines an object to be a
region of memory, formally, the identity of the object changes.
Well, yeah, I wasn't precise either.
The case I was thinking of was creating objects by inserting them in a
list, and using pointers to those objects elsewere.
That is very risky when using a vector, because inserting a new object
may invalidate existing pointers. With a list all you have to remember
is to not destroy any list elements. Until pointer no longer used.
Cheers,
- Alf