This is a question about understanding a design decision, not a complaint about bugs or flaws.
In the C++ standard library, the function to create a shared pointer and its object is a straight function,
template< class T, class... Args> std::shared_ptr<T> make_shared( Args&&... args );
Why is this function not a static function of shared_ptr<T>, like this:
template <class... Args> std::shared_ptr<T>::make(Args&&... args);
This would keep the std:: namespace a little tidier, and would also allow for something like this:
using shared_vector = std::shared_ptr<std::vector<int>>;
shared_vector a = shared_vector::make(7);
The only rationale given in the proposal for
std::make_shared, document N2351, is that it makes it possible to add the functionality non-intrusively to any already existing implementation ofshared_ptr.std::make_sharedwas added to the standard draft afterstd::shared_ptritself and there had been priorshared_ptrimplementations, e.g. in boost.