diff options
Diffstat (limited to 'boost/smart_ptr/make_unique.hpp')
-rw-r--r-- | boost/smart_ptr/make_unique.hpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/boost/smart_ptr/make_unique.hpp b/boost/smart_ptr/make_unique.hpp index d054e3dfe1..eed503392b 100644 --- a/boost/smart_ptr/make_unique.hpp +++ b/boost/smart_ptr/make_unique.hpp @@ -1,10 +1,9 @@ /* -(c) 2014-2015 Glen Joseph Fernandes -<glenjofe -at- gmail.com> +Copyright 2012-2015 Glen Joseph Fernandes +(glenjofe@gmail.com) -Distributed under the Boost Software -License, Version 1.0. -http://boost.org/LICENSE_1_0.txt +Distributed under the Boost Software License, Version 1.0. +(http://www.boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP #define BOOST_SMART_PTR_MAKE_UNIQUE_HPP @@ -15,6 +14,7 @@ http://boost.org/LICENSE_1_0.txt namespace boost { namespace detail { + template<class T> struct up_if_object { typedef std::unique_ptr<T> type; @@ -56,10 +56,12 @@ template<class T> struct up_element<T[]> { typedef T type; }; + } /* detail */ template<class T> -inline typename detail::up_if_object<T>::type make_unique() +inline typename detail::up_if_object<T>::type +make_unique() { return std::unique_ptr<T>(new T()); } @@ -67,7 +69,7 @@ inline typename detail::up_if_object<T>::type make_unique() #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template<class T, class... Args> inline typename detail::up_if_object<T>::type - make_unique(Args&&... args) +make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } @@ -75,31 +77,34 @@ inline typename detail::up_if_object<T>::type template<class T> inline typename detail::up_if_object<T>::type - make_unique(typename detail::up_remove_reference<T>::type&& value) +make_unique(typename detail::up_remove_reference<T>::type&& value) { return std::unique_ptr<T>(new T(std::move(value))); } template<class T> -inline typename detail::up_if_object<T>::type make_unique_noinit() +inline typename detail::up_if_object<T>::type +make_unique_noinit() { return std::unique_ptr<T>(new T); } template<class T> -inline typename detail::up_if_array<T>::type make_unique(std::size_t n) +inline typename detail::up_if_array<T>::type +make_unique(std::size_t size) { - return std::unique_ptr<T>(new - typename detail::up_element<T>::type[n]()); + return std::unique_ptr<T>(new typename + detail::up_element<T>::type[size]()); } template<class T> inline typename detail::up_if_array<T>::type - make_unique_noinit(std::size_t n) +make_unique_noinit(std::size_t size) { - return std::unique_ptr<T>(new - typename detail::up_element<T>::type[n]); + return std::unique_ptr<T>(new typename + detail::up_element<T>::type[size]); } + } /* boost */ #endif |