Boost logo

Boost Users :

Subject: [Boost-users] [shared_ptr] Better support for allocators
From: Alex Dubov (oakad_at_[hidden])
Date: 2010-10-12 07:10:55


Greetings.

shared_ptr<> can be constructed with both custom allocator and deleter.

However, there's an unfortunate shortcoming: if the held object needs to do
some unusual housekeeping on itself during destruction, it needs to store an
additional copy of the allocator or rely on some other custom functionality.

It would be considerably more convenient, if shared_ptr<> could invoke a custom
deleter with allocator (optionally) supplied:

virtual void sp_counted_impl_pda::dispose()
{
    d_(p_, a_);
}

Another handy alternative is to be able to obtain the allocator out of
shared_ptr<> explicitly, in a manner similar to get_deleter(). Tr1
implementation actually constructs a proxy deleter object around the user
supplied one, which inherits from allocator, but it's impossible to obtain a
reference to it from the outside.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net