Boost logo

Boost :

Subject: Re: [boost] intrusive_ptr design question
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-07-06 11:42:34


On Mon, Jul 6, 2009 at 10:32 AM, Stewart, Robert<Robert.Stewart_at_[hidden]> wrote:
> Zachary Turner wrote:
>>
>> Ok, so let me rephrase then: Is there a case to be made for a more
>> flexible shared_ptr (either through modification or through a new
>> class addition) that allows one to provide custom reference counting
>> semantics much the same way that shared_ptr allows one to provide
>> custom deletion semantics?
>
> I haven't followed your discussion closely, so I may have the wrong idea, but don't you run the risk of mixing the different ref counting techniques on objects of the same type?  If the ref counting scheme isn't part of the smart pointer type, then all instances must do ref counting the same way.

That's correct. The way I have envisioned is analagous to the way
shared_ptr allows you to specify a custom deleter. Whenever a copy is
made, the new copy gets the same deleter. That way all copies agree
on the deletion semantics. As long as all copies of the shared
pointer that refer to the same underlying instance of pointed-to
object agree on reference counting semantics, everything should be ok
right?


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