## STD-DISCUSSION | |

**Subject:** Re: Values of objects

**From:** Hyman Rosen (*hyrosen_at_[hidden]*)

**Date:** 2019-08-28 13:01:58

**Next message:**Hyman Rosen: "Re: Values of objects"**Previous message:**Vladimir Grigoriev: "C++ 20. An explicit specialization of a template friend function with a default template argument."**In reply to:**Tony V E: "Re: Values of objects"**Next in thread:**language.lawyer_at_[hidden]: "Re: Values of objects"

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.

- text/html attachment: attachment

**Next message:**Hyman Rosen: "Re: Values of objects"**Previous message:**Vladimir Grigoriev: "C++ 20. An explicit specialization of a template friend function with a default template argument."**In reply to:**Tony V E: "Re: Values of objects"**Next in thread:**language.lawyer_at_[hidden]: "Re: Values of objects"

STD-DISCUSSION list run by herb.sutter at gmail.com