Boost logo

Boost :

Subject: Re: [boost] intrusive_ptr design question
From: Ulrich Eckhardt (doomster_at_[hidden])
Date: 2009-07-08 15:21:13

On Monday 06 July 2009 17:23:41 Zachary Turner wrote:
> 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?

Maybe it's already there: shared_ptr doesn't care if the passed deleter
actually deletes anything. If you now take an object with an existing
reference count, you just increment that count and pass the function that
decrements it as deleter function to a shared_ptr constructor. This creates a
parallel reference count, but it should be safe. Nothing can pull the object
from under the shared_ptr's feet because it holds a reference. The shared_ptr
doesn't destroy the object either, at most it decrements the reference count.


Boost list run by bdawes at, gregod at, cpdaniel at, john at