Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] Design question about make_shared
From: Max Sobolev (macsmr_at_[hidden])
Date: 2011-06-15 01:58:14

On 15.06.2011 4:16, Loïc Joly wrote:
> Hello everybody,
> I recently wondered about the choice to make make_shared a free
> function, and not a static member function:
> struct A{...}; struct B:A {...};
> shared_ptr<A> ptr = make_shared<B>(arg1,arg2);
> vs
> shared_ptr<A> ptr = shared_ptr<B>::make(arg1, arg2);
> I was wondering if this is just a stylistic choice, or if there are some
> differences?
> Thank you for any information.

free functions are preferable due to decreasing code coupling:

static member have access to other static members, but (non-friendly)
free function doesn't.

think about boost::make_shared<> as yet another constructor for
boost::shared_ptr<> with alternative name :)

Boost list run by bdawes at, gregod at, cpdaniel at, john at