Why does C++11 have `make_shared` but not `make_unique` [duplicate]

According to Herb Sutter in this article it was “partly an oversight”. The article contains a nice implementation, and makes a strong case for using it:

template<typename T, typename ...Args>
std::unique_ptr<T> make_unique( Args&& ...args )
{
    return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
}

Update: The original update has been updated and the emphasis has changed.

Leave a Comment