C++ Logo

sg12

Advanced search

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

From: Nevin Liber <nevin_at_[hidden]>
Date: Thu, 10 Oct 2013 18:08:38 -0500
[Y'know, I really wish replies would by default go the whole ub group...]


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.

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); }
};

If X, Y or Z are pointers, this code is broken! And that is with tuple
being designed *by experts* with this use case in mind. If the committee
can't handle it, what chance do mere mortals have?
-- 
 Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404

Received on 2013-10-11 01:09:20