Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:08:51

0001 /*
0002 Copyright 2012-2019 Glen Joseph Fernandes
0003 (glenjofe@gmail.com)
0004 
0005 Distributed under the Boost Software License, Version 1.0.
0006 (http://www.boost.org/LICENSE_1_0.txt)
0007 */
0008 #ifndef BOOST_SMART_PTR_MAKE_UNIQUE_HPP
0009 #define BOOST_SMART_PTR_MAKE_UNIQUE_HPP
0010 
0011 #include <boost/smart_ptr/detail/sp_type_traits.hpp>
0012 #include <memory>
0013 #include <type_traits>
0014 #include <utility>
0015 
0016 namespace boost {
0017 
0018 template<class T>
0019 inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
0020 make_unique()
0021 {
0022     return std::unique_ptr<T>(new T());
0023 }
0024 
0025 template<class T, class... Args>
0026 inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
0027 make_unique(Args&&... args)
0028 {
0029     return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
0030 }
0031 
0032 template<class T>
0033 inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
0034 make_unique(typename std::remove_reference<T>::type&& value)
0035 {
0036     return std::unique_ptr<T>(new T(std::move(value)));
0037 }
0038 
0039 template<class T>
0040 inline typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T> >::type
0041 make_unique_noinit()
0042 {
0043     return std::unique_ptr<T>(new T);
0044 }
0045 
0046 template<class T>
0047 inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
0048     std::unique_ptr<T> >::type
0049 make_unique(std::size_t size)
0050 {
0051     return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]());
0052 }
0053 
0054 template<class T>
0055 inline typename std::enable_if<detail::sp_is_unbounded_array<T>::value,
0056     std::unique_ptr<T> >::type
0057 make_unique_noinit(std::size_t size)
0058 {
0059     return std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]);
0060 }
0061 
0062 } /* boost */
0063 
0064 #endif