Subject: Re: [ub] Justification for < not being a total order on pointers?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2013-10-17 09:28:12
Nevin Liber <nevin_at_[hidden]> writes:
| On 16 October 2013 10:06, Gabriel s too subtle for even most committee members,
| let alone mere mortals, to get right.Dos Reis <gdr_at_[hidden]> wrote:
| | Â Â Â I would not have trouble telling people (especially notices):
| "Ignore expect
| | talks
| | Â Â Â about operator< on pointers. Â Prefer std::less<T>, unless you meant
| | relationship
| | Â Â Â between objects pointed to, in which use operator<. Â Mean what you
| | and say
| | Â Â Â what you mean."
| | So what about std::less<void>? Â Should people be using it?
| What is wrong about it?
| It requires operator<.Â If people specialize std::less<T> instead adding an
| operator<, it won't work.Â It would be surprising that:
| set<T, less<T>> works, but
| set<T, less<>> does not.
| One of the two motivations for this in n3421 is to not require that the
| argument type in a comparator functor be explicitly specified, but that assumes
| there is an operator< for the type, or possible compiler magic for pointer
| comparisons because of the ub issue.
If your goal is to make std::less an alternate syntax for operator<,
then from that logic, it would not make much difference to require
std::less<void> to use std::less<T> instead of operator<. Therefore,
there would be no difference between
| set<T, less<>>
SG12 list run by herb.sutter at gmail.com