C++ Logo


Advanced search

Re: On "transparently replaceable" in std::vector operations

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 28 Apr 2021 16:13:29 +0100
On Wed, 28 Apr 2021 at 11:53, Giuseppe D'Angelo via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> In such a case, doesn't this sentence guarantee that the pointer now
> points to the new object constructed at that position?
> > http://eel.is/c++draft/basic.memobj#basic.life-8.sentence-1

Right, yeah, sorry. I agree, the pointers and references should continue to
be usable to access the new object (or the original object with the new
value, if the shuffle is accomplished by assignment).

That said, a library implementation that has access to magic could
invalidate the pointers and references if it expends sufficient effort; for
example, pointer tagging.

So allowing the pointers and references to be used after insert would close
off a class of correctness checking; the question is whether at present use
of a pointer/reference (or, indeed, an iterator) after an insert is more
likely to be intentional or a bug.

Received on 2021-04-28 10:13:42