C++ Logo


Advanced search

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

From: language.lawyer_at <language.lawyer_at_[hidden]>
Date: Wed, 23 Jun 2021 13:55:22 +0300
On 23/06/2021 12:49, Lénárd Szolnoki via Std-Discussion wrote:
> Hi,
> In my reading the pointer value itself can become invalid, the pointer doesn't need to change value.

I don't understand what does «value itself can become invalid» mean.
> The value of a trivially copyable type is determined from its value representation.

This is not correct. And it is easy to show counterexamples, especially with pointer values.

> The value representation can only change when the object is accessed.

If assume that accessing a value representation means accessing the object, this claim becomes trivial/tautological/irrefutable. (If a program reads the value representation twice and discovers that it has changed, this is because it accessed the object and thus changed its value representation).

> But a pointer can become invalid without accessing it, therefore it's the value itself that has to become invalid in that case.

The conclusion may follow from the premise, however, the premise feels like your postulate.

> Cheers,
> Lénárd

Received on 2021-06-23 05:55:30