annotate DEPENDENCIES/generic/include/boost/move/make_unique.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 //////////////////////////////////////////////////////////////////////////////
Chris@102 2 //
Chris@102 3 // (C) Copyright Ion Gaztanaga 2006-2014. Distributed under the Boost
Chris@102 4 // Software License, Version 1.0. (See accompanying file
Chris@102 5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@102 6 //
Chris@102 7 // See http://www.boost.org/libs/move for documentation.
Chris@102 8 //
Chris@102 9 //////////////////////////////////////////////////////////////////////////////
Chris@102 10
Chris@102 11 #ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
Chris@102 12 #define BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
Chris@102 13
Chris@102 14 #ifndef BOOST_CONFIG_HPP
Chris@102 15 # include <boost/config.hpp>
Chris@102 16 #endif
Chris@102 17 #
Chris@102 18 #if defined(BOOST_HAS_PRAGMA_ONCE)
Chris@102 19 # pragma once
Chris@102 20 #endif
Chris@102 21
Chris@102 22 #include <boost/move/detail/config_begin.hpp>
Chris@102 23 #include <boost/move/detail/workaround.hpp>
Chris@102 24 #include <boost/move/utility_core.hpp>
Chris@102 25 #include <boost/move/unique_ptr.hpp>
Chris@102 26 #include <cstddef> //for std::size_t
Chris@102 27 #include <boost/move/detail/unique_ptr_meta_utils.hpp>
Chris@102 28 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
Chris@102 29 # include <boost/move/detail/fwd_macros.hpp>
Chris@102 30 #endif
Chris@102 31
Chris@102 32 //!\file
Chris@102 33 //! Defines "make_unique" functions, which are factories to create instances
Chris@102 34 //! of unique_ptr depending on the passed arguments.
Chris@102 35 //!
Chris@102 36 //! This header can be a bit heavyweight in C++03 compilers due to the use of the
Chris@102 37 //! preprocessor library, that's why it's a a separate header from <tt>unique_ptr.hpp</tt>
Chris@102 38
Chris@102 39 #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
Chris@102 40
Chris@102 41 namespace std { //no namespace versioning in clang+libc++
Chris@102 42
Chris@102 43 struct nothrow_t;
Chris@102 44
Chris@102 45 } //namespace std {
Chris@102 46
Chris@102 47 namespace boost{
Chris@102 48 namespace move_upmu {
Chris@102 49
Chris@102 50 //Compile time switch between
Chris@102 51 //single element, unknown bound array
Chris@102 52 //and known bound array
Chris@102 53 template<class T>
Chris@102 54 struct unique_ptr_if
Chris@102 55 {
Chris@102 56 typedef ::boost::movelib::unique_ptr<T> t_is_not_array;
Chris@102 57 };
Chris@102 58
Chris@102 59 template<class T>
Chris@102 60 struct unique_ptr_if<T[]>
Chris@102 61 {
Chris@102 62 typedef ::boost::movelib::unique_ptr<T[]> t_is_array_of_unknown_bound;
Chris@102 63 };
Chris@102 64
Chris@102 65 template<class T, std::size_t N>
Chris@102 66 struct unique_ptr_if<T[N]>
Chris@102 67 {
Chris@102 68 typedef void t_is_array_of_known_bound;
Chris@102 69 };
Chris@102 70
Chris@102 71 template <int Dummy = 0>
Chris@102 72 struct nothrow_holder
Chris@102 73 {
Chris@102 74 static std::nothrow_t *pnothrow;
Chris@102 75 };
Chris@102 76
Chris@102 77 template <int Dummy>
Chris@102 78 std::nothrow_t *nothrow_holder<Dummy>::pnothrow;
Chris@102 79
Chris@102 80 } //namespace move_upmu {
Chris@102 81 } //namespace boost{
Chris@102 82
Chris@102 83 #endif //!defined(BOOST_MOVE_DOXYGEN_INVOKED)
Chris@102 84
Chris@102 85 namespace boost{
Chris@102 86 namespace movelib {
Chris@102 87
Chris@102 88 #if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
Chris@102 89
Chris@102 90 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
Chris@102 91 //!
Chris@102 92 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::forward<Args>(args)...))</tt>.
Chris@102 93 template<class T, class... Args>
Chris@102 94 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 95 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
Chris@102 96 make_unique(BOOST_FWD_REF(Args)... args)
Chris@102 97 { return unique_ptr<T>(new T(::boost::forward<Args>(args)...)); }
Chris@102 98
Chris@102 99 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
Chris@102 100 //!
Chris@102 101 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::nothrow)(std::forward<Args>(args)...))</tt>.
Chris@102 102 template<class T, class... Args>
Chris@102 103 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 104 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
Chris@102 105 make_unique_nothrow(BOOST_FWD_REF(Args)... args)
Chris@102 106 { return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T(::boost::forward<Args>(args)...)); }
Chris@102 107
Chris@102 108 #else
Chris@102 109 #define BOOST_MOVE_MAKE_UNIQUE_CODE(N)\
Chris@102 110 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
Chris@102 111 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
Chris@102 112 make_unique( BOOST_MOVE_UREF##N)\
Chris@102 113 { return unique_ptr<T>( new T( BOOST_MOVE_FWD##N ) ); }\
Chris@102 114 \
Chris@102 115 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
Chris@102 116 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
Chris@102 117 make_unique_nothrow( BOOST_MOVE_UREF##N)\
Chris@102 118 { return unique_ptr<T>( new (*boost::move_upmu::nothrow_holder<>::pnothrow)T ( BOOST_MOVE_FWD##N ) ); }\
Chris@102 119 //
Chris@102 120 BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_MAKE_UNIQUE_CODE)
Chris@102 121 #undef BOOST_MOVE_MAKE_UNIQUE_CODE
Chris@102 122
Chris@102 123 #endif
Chris@102 124
Chris@102 125 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
Chris@102 126 //!
Chris@102 127 //! <b>Returns</b>: <tt>unique_ptr<T>(new T)</tt> (default initialization)
Chris@102 128 template<class T>
Chris@102 129 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 130 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
Chris@102 131 make_unique_definit()
Chris@102 132 {
Chris@102 133 return unique_ptr<T>(new T);
Chris@102 134 }
Chris@102 135
Chris@102 136 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is not an array.
Chris@102 137 //!
Chris@102 138 //! <b>Returns</b>: <tt>unique_ptr<T>(new T(std::nothrow)</tt> (default initialization)
Chris@102 139 template<class T>
Chris@102 140 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 141 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
Chris@102 142 make_unique_nothrow_definit()
Chris@102 143 {
Chris@102 144 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T);
Chris@102 145 }
Chris@102 146
Chris@102 147 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
Chris@102 148 //! unknown bound.
Chris@102 149 //!
Chris@102 150 //! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n]())</tt> (value initialization)
Chris@102 151 template<class T>
Chris@102 152 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 153 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
Chris@102 154 make_unique(std::size_t n)
Chris@102 155 {
Chris@102 156 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
Chris@102 157 return unique_ptr<T>(new U[n]());
Chris@102 158 }
Chris@102 159
Chris@102 160 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
Chris@102 161 //! unknown bound.
Chris@102 162 //!
Chris@102 163 //! <b>Returns</b>: <tt>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n]())</tt> (value initialization)
Chris@102 164 template<class T>
Chris@102 165 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 166 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
Chris@102 167 make_unique_nothrow(std::size_t n)
Chris@102 168 {
Chris@102 169 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
Chris@102 170 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)U[n]());
Chris@102 171 }
Chris@102 172
Chris@102 173 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
Chris@102 174 //! unknown bound.
Chris@102 175 //!
Chris@102 176 //! <b>Returns</b>: <tt>unique_ptr<T>(new remove_extent_t<T>[n])</tt> (default initialization)
Chris@102 177 template<class T>
Chris@102 178 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 179 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
Chris@102 180 make_unique_definit(std::size_t n)
Chris@102 181 {
Chris@102 182 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
Chris@102 183 return unique_ptr<T>(new U[n]);
Chris@102 184 }
Chris@102 185
Chris@102 186 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is an array of
Chris@102 187 //! unknown bound.
Chris@102 188 //!
Chris@102 189 //! <b>Returns</b>: <tt>unique_ptr<T>(new (std::nothrow)remove_extent_t<T>[n])</tt> (default initialization)
Chris@102 190 template<class T>
Chris@102 191 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
Chris@102 192 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
Chris@102 193 make_unique_nothrow_definit(std::size_t n)
Chris@102 194 {
Chris@102 195 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
Chris@102 196 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow) U[n]);
Chris@102 197 }
Chris@102 198
Chris@102 199 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
Chris@102 200
Chris@102 201 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
Chris@102 202 //! an array of known bound.
Chris@102 203 template<class T, class... Args>
Chris@102 204 inline BOOST_MOVE_DOC1ST(unspecified,
Chris@102 205 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
Chris@102 206 make_unique(BOOST_FWD_REF(Args) ...) = delete;
Chris@102 207
Chris@102 208 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
Chris@102 209 //! an array of known bound.
Chris@102 210 template<class T, class... Args>
Chris@102 211 inline BOOST_MOVE_DOC1ST(unspecified,
Chris@102 212 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
Chris@102 213 make_unique_definit(BOOST_FWD_REF(Args) ...) = delete;
Chris@102 214
Chris@102 215 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
Chris@102 216 //! an array of known bound.
Chris@102 217 template<class T, class... Args>
Chris@102 218 inline BOOST_MOVE_DOC1ST(unspecified,
Chris@102 219 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
Chris@102 220 make_unique_nothrow(BOOST_FWD_REF(Args) ...) = delete;
Chris@102 221
Chris@102 222 //! <b>Remarks</b>: This function shall not participate in overload resolution unless T is
Chris@102 223 //! an array of known bound.
Chris@102 224 template<class T, class... Args>
Chris@102 225 inline BOOST_MOVE_DOC1ST(unspecified,
Chris@102 226 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
Chris@102 227 make_unique_nothrow_definit(BOOST_FWD_REF(Args) ...) = delete;
Chris@102 228
Chris@102 229 #endif
Chris@102 230
Chris@102 231 } //namespace movelib {
Chris@102 232
Chris@102 233 } //namespace boost{
Chris@102 234
Chris@102 235 #include <boost/move/detail/config_end.hpp>
Chris@102 236
Chris@102 237 #endif //#ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED