C++ Logo

sg12

Advanced search

Re: [ub] Justification for < not being a total order on pointers?

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Thu, 10 Oct 2013 18:24:09 -0500
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.

Correct.

| 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
pointers.

| 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

Received on 2013-10-11 01:24:27