Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2006-07-18 18:24:18


On 7/10/06 8:15 PM, "Sohail Somani" <s.somani_at_[hidden]> wrote:

>[me22 wrote (on 7/10/06 @ 5:07 pm):]
>> On 7/10/06, Sohail Somani <s.somani_at_[hidden]> wrote:
>>> Isn't shared_ptr<T> is supposed to be like T* which has ordering? In
>>> this case, it's a non-issue no?
>>>
>> My understanding is that < is only well-defined for pointers into the
>> same array and that < between to arbitrary pointers is otherwise some
>> sort of UB.
>>
>> It's less<T*> that provides a full ordering for arbitrary T*s. (By
>> specialising std::less.)
>
> Sorry for the double email, but I guess with this information at least we
> can verify that operator < is using less?

No. For pointers going into the same array segment (including one-past-end)
or the same access-level class block, operator "<" is defined. Using the
operator is unspecified if the pointers are from different spans. The
"std::less<T*>" specializations have to give the same results as the
operator when the operator is defined, but must give a total ordering so
pointers from different spans (or NULL) can be compared. Due to potential
exclusivities in comparison domains, it's possible that the operator and the
class template use separate definitions.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk