
15 Jun
2011
15 Jun
'11
5:58 a.m.
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 :)