Subject: Re: Values of objects
From: Hyman Rosen (hyrosen_at_[hidden])
Date: 2019-08-28 13:01:58
On Wed, Aug 28, 2019 at 1:02 PM Tony V E <tvaneerd_at_[hidden]> wrote:
> How does that interact with == ?
> Typically we consider equal things to have equal values and == returns
> true iff values are equal.
> Consider -0 == 0, for example. And in general, a user-defined class can
> have the same "value" stored with different bit representations.
The value of an object is the sequence of bits in its value representation.
Operator== is a function that maps an ordered pair of objects to a boolean.
Since, as you point out, operator== very often does not imply that two
objects have the same value representation (NaN is a prominent example),
it seems useful to distinguish "same" from "equal". Then two objects have
the same value if their value representations consist of the same/equal
sequence of bits (hopefully, that usage is unambiguous!), and two objects
are equal if operator== returns true.
STD-DISCUSSION list run by herb.sutter at gmail.com
Older Archives on Google Groups