$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [shared_ptr] Design question about make_shared
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-06-15 07:15:27
Stephan T. Lavavej wrote:
> Right, that's what I was trying to say - internally, they are coupled, yet 
> make_shared goes out of its way to be a free function.
My initial implementation of boost::make_shared was a self-contained header 
that didn't require any changes to shared_ptr (it would have worked with 
std::tr1::shared_ptr as well as it worked with boost::shared_ptr). This can 
only be done with a free function.
Now, this copied around the deleter a few times more than necessary and 
created problems with over-aligned types, so you're right that an optimized 
implementation needs support from shared_ptr. :-) (However, it can be argued 
that this support - the ability to ask for a deleter of a specific type to 
be default-constructed in place by shared_ptr - should be offered to users 
as well, not just to make_shared.)