Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] Why operator< uses internal_less?
From: emil_at_[hidden]
Date: 2008-10-09 21:16:35


On 10/9/08, Peter Dimov <pdimov_at_[hidden]> wrote:
> Frank Mori Hess:
>> On Thursday 09 October 2008 11:32 am, Sebastian Redl wrote:
>>> dariomt_at_[hidden] wrote:
>>> > I see that operator== and operator!= are implemented comparing the
>>> > pointer inside the shared_ptr's using get(), but operator< uses
>>> > _internal_less, that does a different thing.
>>> >
>>> > I thought that operator< would also be implemented using get(), so
>>> > please, can you share the rationale behind the need for _internal_less?
>>>
>>> get() returns px (the raw pointer), _internal_less compares pn (the
>>> shared_count).
>>>
>>> This is peculiar, since it means that alias pointers to different
>>> subobjects would compare non-equal, but sort equivalent. I'd like to
>>> know the rationale of this, too.
> http://open-std.org/JTC1/SC22/WG21/docs/papers/2004/n1590.html
>
> At the last meeting, the committee accepted Herve Broenimann's proposal
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2637.pdf
>
> to change std::shared_ptr's operator< to compare get(). I don't particularly
> like the specifics of that paper, but we'll probably need to change
> boost::shared_ptr (and weak_ptr) to match.

I don't see a reason to make this change in Boost. It is impossible to predict how many bugs it will introduce in user code, although it could -- perhaps too late -- highlight problems unforeseen by N2637. IMHO, the committee is crazy for making this kind of untested semantic changes in shared_ptr this late in the game.

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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