Why does C++11 have `make_shared` but not `make_unique`
c++, c++11
Solution
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.
Problem
Possible Duplicate: make_unique and perfect forwarding Why does C++11 have a `make_shared` template, but not a `make_unique` template? This makes code very inconsistent. ``` auto x = make_shared<string>("abc"); auto y = unique_ptr<string>(new string("abc")); ```