/* (c) 2014-2015 Glen Joseph Fernandes Distributed under the Boost Software License, Version 1.0. http://boost.org/LICENSE_1_0.txt */ #ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP #define BOOST_SMART_PTR_MAKE_UNIQUE_HPP #include #include #include namespace boost { namespace detail { template struct up_if_object { typedef std::unique_ptr type; }; template struct up_if_object { }; template struct up_if_object { }; template struct up_if_array { }; template struct up_if_array { typedef std::unique_ptr type; }; template struct up_remove_reference { typedef T type; }; template struct up_remove_reference { typedef T type; }; template struct up_remove_reference { typedef T type; }; template struct up_element { }; template struct up_element { typedef T type; }; } /* detail */ template inline typename detail::up_if_object::type make_unique() { return std::unique_ptr(new T()); } #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template inline typename detail::up_if_object::type make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } #endif template inline typename detail::up_if_object::type make_unique(typename detail::up_remove_reference::type&& value) { return std::unique_ptr(new T(std::move(value))); } template inline typename detail::up_if_object::type make_unique_noinit() { return std::unique_ptr(new T); } template inline typename detail::up_if_array::type make_unique(std::size_t n) { return std::unique_ptr(new typename detail::up_element::type[n]()); } template inline typename detail::up_if_array::type make_unique_noinit(std::size_t n) { return std::unique_ptr(new typename detail::up_element::type[n]); } } /* boost */ #endif