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

Nevin Liber nevin at eviloverlord.com
Wed Oct 16 17:15:19 CEST 2013


On 15 October 2013 18:14, Gabriel Dos Reis <gdr at microsoft.com> wrote:

> Nevin --
> Are you asking that operator< be a total order on std::deque<T>::iterator?
>

No, although the only sentence I can find in n3797 not requiring it today
is in iterator requirements in general 24.2.1p7: "The result of the
application of functions in the library to invalid ranges is undefined" and
assuming that operator< has to be implemented with a function so that the
assertion in table 111 that "< is a total ordering relation" only holds for
valid ranges.

My goal is that for two objects l and r of type T, 'std::less<T>(l, r)',
'std::less<>(l, r)' and 'l < r' should never diverge, because anything else
makes usage expert-only.
-- 
 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/c3840bb8/attachment.html 


More information about the ub mailing list