Exception safety issue of std::make_unique()
问题 From this thread, we know that the following code is exception-safe (assuming that T( U(std::move(v)) ) is exception-safe, e.g., does not throw, which is library user's responsibility). auto p = new T( U(std::move(v)) ); The key point here is that the initializer expression U(std::move(v)) is evaluated after memory allocation. Now consider the std::make_unique() counterpart. auto p = std::make_unique<T>( U(std::move(v)) ); The initializer expression U(std::move(v)) is evaluated even before