
Joe Gottman wrote:
"Vaclav Vesely" <vaclav.vesely@email.cz> wrote in message news:e00i2r$6a8$1@sea.gmane.org...
[...]
void ok2() { f(new_shared_ptr<int>(2), g()); }
Another possible advantage of new_shared_ptr mentioned by the article is that it could reduce the number of news required to create the shared_ptr from 2 to 1. In the code shared_ptr<int> p(new int(7)); new is called twice: when the int is created and inside the shared_ptr's constructor to construct an object of a type inheriting from boost::sp_counted_base.
This is also what N1851 proposes, with a different spelling: make_shared_object, make_shared_object_with_alloc, make_shared_array. It's an additional argument in favor of new_shared_ptr instead of new_< shared_ptr >, if nothing else. There's also the alternative of shared_ptr<X>::create( a1, ..., aN ).