Date: Wed, 16 Oct 2013 10:37:12 -0500
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
| a
| | relationship
| | between objects pointed to, in which use operator<. Mean what you
| say
| | 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.
That is an issue with the definition of std::less<>, not necessarily
with operator< on pointers.
| 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 :-)
|
| 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.
| 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
| a
| | relationship
| | between objects pointed to, in which use operator<. Mean what you
| say
| | 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.
That is an issue with the definition of std::less<>, not necessarily
with operator< on pointers.
| 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 :-)
|
| 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.
Received on 2013-10-16 17:37:28