Date: Wed, 28 Apr 2021 12:52:51 +0200
Il 28/04/21 11:01, Edward Catmur via Std-Discussion ha scritto:
>
> Still, there's probably some combination of noexcept specifications that
> makes the shuffle by destruct-and-move preferable.
Suppose that one has got a pointer to a position inside a
`std::vector<X>`, and a (non-reallocating) operation on the vector
decides, for whatever reason, to destroy the object at that position and
then construct a new one. Is that the scenario you're envisioning?
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
> If, after the lifetime of an object has ended and before the storage which the
> object occupied is reused or released, a new object is created at the storage
> location which the original object occupied, a pointer that pointed to the
> original object, a reference that referred to the original object, or the name
> of the original object will automatically refer to the new object and, once the
> lifetime of the new object has started, can be used to manipulate the new
> object, if the original object is transparently replaceable (see below) by the
> new object.
Thank you,
>
> Still, there's probably some combination of noexcept specifications that
> makes the shuffle by destruct-and-move preferable.
Suppose that one has got a pointer to a position inside a
`std::vector<X>`, and a (non-reallocating) operation on the vector
decides, for whatever reason, to destroy the object at that position and
then construct a new one. Is that the scenario you're envisioning?
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
> If, after the lifetime of an object has ended and before the storage which the
> object occupied is reused or released, a new object is created at the storage
> location which the original object occupied, a pointer that pointed to the
> original object, a reference that referred to the original object, or the name
> of the original object will automatically refer to the new object and, once the
> lifetime of the new object has started, can be used to manipulate the new
> object, if the original object is transparently replaceable (see below) by the
> new object.
Thank you,
-- Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer KDAB (France) S.A.S., a KDAB Group company Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com KDAB - The Qt, C++ and OpenGL Experts
Received on 2021-04-28 05:52:57