C++ Logo


Advanced search

Subject: Re: [ub] Justification for < not being a total order on pointers?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2013-10-10 18:24:09

Nevin Liber <nevin_at_[hidden]> writes:

| [Y'know, I really wish replies would by default go the whole ub group...]

I cannot control your email software, but when you sent me the message,
it wasn't addressed to the group and I replied the same way.

| On 10 October 2013 17:35, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
| I don’t know because I don’t have access to all machines, nor did anybody
| came forward with that universal knowledge.
| I am seriously hoping that we would NOT claim ‘willful ignorance’ as basis
| for design. 
| I thought one of the design principles discussed today in another forum was to
| make the language and library less expert-only.


| The fact that pointers may not be totally ordered makes any comparison of them
| in the realm of experts only.

Obviiously, I don't subscribe to that view.

As observed by Sean Parent in another discussion, std::less<T*> as a
total order was never meant to be synonymous for operator< on pointers.
There is nothing expert-only about that, since operator< has been been
documented or thought in any C++ material I know as a total order on

| If someone writes:
| struct Foo
| {
|     X x;
|     Y y;
|     Z z;
|     friend bool operator<(Foo const& l, Foo const& r)
|     { return std::tie(l.x, l.y, l.z) < std::tie(r.x, r.y, r.z); }

in my book, that someone writing this isn't a novice, but we have
already disagreed on this.

| };
| If X, Y or Z are pointers, this code is broken!

If X, Y, and Z are pointers, I don't think he or she would have written that.

-- Gaby

SG12 list run by herb.sutter at gmail.com