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

Gabriel Dos Reis gdr at axiomatics.org
Wed Oct 16 17:50:59 CEST 2013


Nevin Liber <nevin at eviloverlord.com> writes:

| On 16 October 2013 10:37, Gabriel Dos Reis <gdr at axiomatics.org> 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


More information about the ub mailing list