make_unique

This commit is contained in:
Andrei Astafev 2020-07-09 15:05:59 +03:00
parent 11866bf3ba
commit de1c396a5e

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#if ( __cplusplus >= 201103L ) #if ( __cplusplus >= 201103L )
#include <memory>
#include <type_traits> #include <type_traits>
#endif #endif
@ -15,6 +16,12 @@ namespace std
template< class T > template< class T >
using underlying_type_t = typename std::underlying_type< T >::type; using underlying_type_t = typename std::underlying_type< T >::type;
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
} // namespace std } // namespace std
#endif #endif