Boost logo

Boost Users :

Subject: Re: [Boost-users] make_shared and custom deleter
From: Dominique Devienne (ddevienne_at_[hidden])
Date: 2009-05-28 17:00:58

On Thu, May 28, 2009 at 9:48 AM, Frank Mori Hess <frank.hess_at_[hidden]> wrote:
> On Wednesday 27 May 2009, Dominique Devienne wrote:
>> I was thinking of using the new make_shared, but I'm already using a
>> custom deleter (shared instances have private destructors and declare
>> the custom deleter as a friend, and new instances are returned wrapped
>> in shared_ptr, thus no explicit new or delete should be possible).
>> Looking at make_shared, I can't see a way to use both at the same
>> time. Am I out of luck? Thanks, --DD
> You can't, not even with boost::allocate_shared since it doesn't use the
> allocator for in-place construction.  See ticket #2481:
> In theory you should be able to use std::allocate_shared in c++0x mode if your
> compiler provides it.  Define your own allocator (a bit of a pain) and make
> it a friend of your class.  Then add a static factory function to your class
> with calls allocate_shared with your friend allocator.

I'm not quite following everything but sounds like I can't have it
both ways for now. And I can't use C++0x, so I'll forget about
make_shared for the moment. Thanks for answering though. --DD

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at