Subject: Re: [ub] Justification for < not being a total order on pointers?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2013-10-10 20:37:30
Nevin Liber <nevin_at_[hidden]> writes:
| On 10 October 2013 18:24, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
| 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.
| It isn't my software (Gmail web client); it's the mailing list. Â All the other
| reflectors default to replying to the group; this one defaults to replying only
| to the original author. Â I'm not sure who to contact to get that changed.
I believe the setting is the same as for all the other SG mailing lists
that run on isocpp.open-std.org. I will check.
[ when I receive I message not sent to the list I always treat it as
a concious decision from the sender as private message, otherwise
he or she would have hit the "reply all" button (which I believe is
also available in Gmail. ]
| 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.
| Sean also says inÂ [c++std-lib-ext-550]:Â The definition ofÂ std::lessÂ should be
| "a representational order if no natural total order (operatorÂ <) is available,
| otherwise the natural total order". Â He goes on: "They are named separately,Â
| operator<() is the natural total order andÂ std::less<> is the natural total
| order if one exists, otherwise it is a representational order."
| Pointers clearly violate those rules.
Sean will speak for himself, but I don't think he was making the point
that operator< on pointers was a total order. My reading of his message
was the opposite.
| Of course, C++ experts live with these contradictory rules all the time.
I think there is a debate about what is perceived as contradictory.
| Â That's what makes them experts... :-(
I must confess I do not understand why saying that for "p < q" to make
sense, the addresses must be related is an expert-level thing.
Certainly, we don't claim that for two random iterators p and q, the
expression p < q must make sense whether p and q are related. Are we?
I've not seen novices wanting to do anything sensible in a conditional
based on p < q when the addresses are not related. I have seen lot of
examples by experts, though. Most novices I've met or delt with come
with a background where the notion of pointer comparison does not even
exist to start with...
| Â Some experts even argue we should keep this contradictory behavior
| without providing concrete reasons why it is still necessary.
Do you have links to such statements?
SG12 list run by herb.sutter at gmail.com