Boost logo

Boost :

From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-10-11 08:44:10

Peter Dimov wrote:
> Phil Endecott:
>> Vladimir Batov wrote:
>>> Given I've been using this Pimpl idiom quite extensively lately I've
>>> noticed
>>> writing the same scaffolding over and over again.
>> Maybe we need something with a mixture of features from scoped_ptr and
>> shared_ptr. scoped_ptr does everything that I need for a pimpl, except
>> that it can't delete the incomplete implementation type. shared_ptr
>> can delete the incomplete implementation, but it has the unneeded
>> overhead of reference counting and thread safety issues. So, can the
>> incomplete deletion feature of shared_ptr be extracted and added to
>> scoped_ptr? I have just had a quick look at the shared_ptr
>> implementation to see how deletion works, but it's too clever for me to
>> understand....
> Alan Griffiths has written a similar smart pointer, arg::grin_ptr:

Thanks Peter, that's exactly what's needed. And very well described by
Alan on that page.

It seems that the trick needed to allow incomplete types to be deleted
is the same one that allows a shared_ptr to be given a custom deleter,
e.g. so that I can free() things that have been malloc()ed by C code.
A smart pointer with these features would be great for Boost.

Vladimir, would you like to revise your pimpl template to use this?

Regards, Phil.

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