Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if (__cplusplus >= 201103L) || (defined _MSC_VER && _MSC_VER >= 1600)
- #include <memory>
- #include <functional>
- # ifdef _MSC_VER
- template <typename Type>
- inline std::unique_ptr<Type> make_unique() {
- return std::unique_ptr<Type>(new Type());
- }
- template <typename Type, typename Arg1>
- inline std::unique_ptr<Type> make_unique(Arg1&& arg1) {
- return std::unique_ptr<Type>(new Type(std::forward<Arg1>(arg1)));
- }
- template <typename Type, typename Arg1, typename Arg2>
- inline std::unique_ptr<Type> make_unique(Arg1&& arg1, Arg2&& arg2) {
- return std::unique_ptr<Type>(new Type(std::forward<Arg1>(arg1), std::forward<Arg2>(arg2)));
- }
- # else
- template <typename Type, typename... Args>
- inline std::unique_ptr<Type> make_unique(Args... args) {
- return std::unique_ptr<Type>(new Type(std::forward<Args>(args)...));
- }
- # endif
- #else
- # error ISO C++ 2011 standard is not enabled
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement