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:50:59 -0500
Nevin Liber <nevin_at_[hidden]> writes:

| On 16 October 2013 10:37, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
|
|
| | It would be surprising that:
| |
| | set<T, less<T>> works, but
| | set<T, less<>> does not.
|
| Make T = std::less<std::complex<MyFloat>> and instantiate the argument :-)
|
|
| Neither operator< nor less<complex> is defined by the standard.

Exactly! I said std::less<std::complex<MyFloat>>, which has always been
supposed to be user-provided, when defined. Since C++98. And codes
like that exist. The relation with your argument is that those C++98
codes will continue to work today with C++11, while the version with
less<void> will fail. Miresably.

Short version: the argument of the definition of less<T> vs. less<void>
isn't compelling.

Now, I've to dash to work; will your replies later.

-- Gaby

Received on 2013-10-16 17:51:14