[shared_ptr] Better support for allocators
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.
participants (1)
-
Alex Dubov