C++ Logo

sg12

Advanced search

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

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Wed, 16 Oct 2013 10:53:34 -0500
Ville Voutilainen <ville.voutilainen_at_[hidden]> writes:

| On 16 October 2013 18:46, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
|
|
| | My own personal view (not that of chair) is that if std::less<T>(l,r)
| and
| | "l < r" are
| | both defined, then they should yield the same answer.
| |
| |
| | Which fails for pointers.
|
| "fails" in which sense? It is certainly true in the current standards
| these expressions are both defined when 'l' and 'r' are related
| addresses (relative to the same object), which was exactly my point.
|
| Fails in the sense that less<int*>(l, r) and l<r do not necessarily yield the
| same answer.

Only on the cases, e.g. input values, where they aren't both defined.
That isn't failure. You're looking at the value of the proposition when the
preconditions aren't satisfied, we all know what happens :-)

-- Gaby

Received on 2013-10-16 17:53:47