Boost logo

Boost :

Subject: Re: [boost] [shared_ptr] Design question about make_shared
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2011-06-15 02:56:04


[Loïc Joly]
> I was wondering if this is just a stylistic choice, or if there are some
> differences?

Unless I'm missing something, it's purely stylistic:

* make_shared<T>() is less typing (with less punctuation) than shared_ptr<T>::make().

* What would you call allocate_shared<T>()?

* It is similar to make_pair()/make_tuple(), although different in effect.

The notable thing is that C++0x lacks make_unique<T>(), which it should really have.

[Max Sobolev]
> free functions are preferable due to decreasing code coupling:

Actually, make_shared<T>() needs access to shared_ptr's guts, at least if the implementer takes advantage of the obvious and highly desirable optimization. They are tightly coupled to begin with.

Stephan T. Lavavej
Visual C++ Libraries Developer
(I obviously didn't design make_shared<T>(), but I have implemented it.)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk