Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-08-26 12:42:21


On Tuesday 26 August 2003 01:23 pm, Peter Dimov wrote:
> Leaving aside the issue of whether specializing std::allocator<MyClass> is
> a good idea:
>
> shared_ptr< MyClass, MyAllocator > s;
>
> note that you now wouldn't be able to pass s to a function that expects
> shared_ptr<MyClass> since the type is not the same.

There's no reason shared_ptr couldn't support a constructor that takes an
allocator as an argument. Then sp_counted_base_impl would also take an
Allocator parameter (heh, the allocator it was in fact allocated with) and
would know how to deallocate itself via a (copy of) this allocator. We'd get
allocator support without putting the allocator into the type of shared_ptr
(just like we have deleter support).

        Doug


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