C++ Logo

std-discussion

Advanced search

Re: Values of objects

From: Hyman Rosen <hyrosen_at_[hidden]>
Date: Wed, 28 Aug 2019 15:05:19 -0400
On Wed, Aug 28, 2019 at 2:53 PM Krystian Stasiowski via Std-Discussion <
std-discussion_at_[hidden]> wrote:

> > The right way to define this is to say that objects have a value
> representation consisting
> of a fixed subset of the bits of their object representation, and that the
> value of an object
> is the sequence of bits in the value representation.
>
> Not quite, while the value representation of an trivially copyable type
> will appear in the object representation, for an object of non-trivially
> copyable type, the value is a user established thing: such as
> `std::string`, since it has a pointer to external data.
>

Not not quite. Pick your own words if you want, but we should have one word
for the contents of the value representation and another for the
"user-established
thing". I like "same" for the former and "equal" for the latter, so two
std::string
objects are the same if they point to the same external data (makes more
sense
for string views), and are equal if they point to identical sequences of
characters.

Received on 2019-08-28 14:07:34