C++ Logo


Advanced search

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

From: Christopher Jefferson <chris_at_[hidden]>
Date: Wed, 16 Oct 2013 22:43:19 +0100
On 16 October 2013 22:25, Nevin Liber <nevin_at_[hidden]> wrote:
> On 16 October 2013 16:15, Christopher Jefferson <chris_at_[hidden]>
> wrote:
>> On 16 October 2013 00:14, Gabriel Dos Reis <gdr_at_[hidden]> 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:

You (and Stephan) are right, it would be for Visual Studio (and that
is reasonable). gcc (which is what I looked at) stores a raw pointer
to the current value, and compares first the parent pointer, and then
that raw pointer. Here a complete ordering on raw pointers would
naturally give a complete ordering on deque iterators.


Received on 2013-10-16 23:43:20