[ub] Justification for < not being a total order on pointers?
Nevin Liber
nevin at eviloverlord.com
Wed Oct 16 17:31:11 CEST 2013
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 microsoft.com>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. 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<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3421.htm>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.
--
Nevin ":-)" Liber <mailto:nevin at eviloverlord.com> (847) 691-1404
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/ub/attachments/20131016/45cd1fe8/attachment.html
More information about the ub
mailing list