Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-02-02 21:51:43

Larry Evans <cppljevans_at_[hidden]> writes:

> On 02/02/2004 10:32 AM, Javier Estrada wrote:
>>>Custom deleters are your friend.
>> How about custom allocators AND deleters?
>> The reason I say this is because it would be useful to have a
>> policy-based
>> approach when interacting with APIs that do the allocation/destruction.
> But instead of placing two pointers(1 for allocator + 1 for deleter) why
> not use a virtual function table for both? In other words, instead of
> just having a sp_counted_base::dispose + destruct, why not add an
> virtual allocate? Then, instead of passing the deleter as an argument
> to the CTOR, a sp_counted_base* would be passed and the user would
> define a subclass of sp_counted_base which used whatever allocator
> and destructor desired. This would save some memory and wouldn't
> (I don't think) constrain the user much since I don't think the user
> would want a separate destructor and allocator for each instance of
> the shared object.

What's the point of storing an allocator? Once the storage for the
deleter is allocated, a shared_ptr never needs to allocate again.

Dave Abrahams
Boost Consulting

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