[ub] Justification for < not being a total order on pointers?
Nevin Liber
nevin at eviloverlord.com
Wed Oct 16 23:25:19 CEST 2013
On 16 October 2013 16:15, Christopher Jefferson <chris at bubblescope.net>wrote:
> On 16 October 2013 00:14, Gabriel Dos Reis <gdr at microsoft.com> wrote:
> > Nevin --
> > Are you asking that operator< be a total order on
> std::deque<T>::iterator?
> >
>
> On a practical note, I believe this would arise naturally, if
> operator< was a total order on pointers.
No, it does not. It would be a pessimization. As pointed out on the LWG
reflector:
On 16 October 2013 13:25, Stephan T. Lavavej <stl at exchange.microsoft.com>wrote:
> There is an efficiency concern here. Our deque iterators are represented
> with a parent pointer and an index, and op< compares only the index (same
> for op==). If we had to provide a total order, we'd need to insert extra
> instructions.
> Also at the moment there
> isn't an alternative, because there isn't a
> std::less<std::deque<T>::iterator>.
>
(A) Sure there is; it just calls down to operator<.
(B) It doesn't provide any more of a guarantee of total ordering than
operator< does.
--
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/5b51a04b/attachment-0001.html
More information about the ub
mailing list