File indexing completed on 2026-09-15 08:51:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
0012 #define BOOST_MOVE_MAKE_UNIQUE_HPP_INCLUDED
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 0018 ">#
0019 #if defined(BOOST_HAS_PRAGMA_ONCE)
0020 # pragma once
0021 #endif
0022
0023 #include <boost/move/detail/config_begin.hpp>
0024 #include <boost/move/detail/workaround.hpp>
0025 #include <boost/move/utility_core.hpp>
0026 #include <boost/move/unique_ptr.hpp>
0027 #include <cstddef> //for std::size_t
0028 #include <boost/move/detail/unique_ptr_meta_utils.hpp>
0029 #ifdef BOOST_NO_CXX11_VARIADIC_TEMPLATES
0030 # include <boost/move/detail/fwd_macros.hpp>
0031 #endif
0032
0033
0034
0035
0036
0037
0038
0039
0040 #if !defined(BOOST_MOVE_DOXYGEN_INVOKED)
0041
0042 #if defined(_MSC_VER) && (_MSC_VER >= 1915)
0043 #pragma warning (push)
0044 #pragma warning (disable : 4643)
0045 #endif
0046
0047 namespace std {
0048
0049 struct nothrow_t;
0050
0051 }
0052
0053 #if defined(_MSC_VER) && (_MSC_VER >= 1915)
0054 #pragma warning (pop)
0055 #endif
0056
0057
0058 namespace boost{
0059 namespace move_upmu {
0060
0061
0062
0063
0064 template<class T>
0065 struct unique_ptr_if
0066 {
0067 typedef ::boost::movelib::unique_ptr<T> t_is_not_array;
0068 };
0069
0070 template<class T>
0071 struct unique_ptr_if<T[]>
0072 {
0073 typedef ::boost::movelib::unique_ptr<T[]> t_is_array_of_unknown_bound;
0074 };
0075
0076 template<class T, std::size_t N>
0077 struct unique_ptr_if<T[N]>
0078 {
0079 typedef void t_is_array_of_known_bound;
0080 };
0081
0082 template <int Dummy = 0>
0083 struct nothrow_holder
0084 {
0085 static std::nothrow_t *pnothrow;
0086 };
0087
0088 template <int Dummy>
0089 std::nothrow_t *nothrow_holder<Dummy>::pnothrow =
0090 reinterpret_cast<std::nothrow_t *>(0x1234);
0091
0092 }
0093 }
0094
0095 #endif
0096
0097 namespace boost{
0098 namespace movelib {
0099
0100 #if defined(BOOST_MOVE_DOXYGEN_INVOKED) || !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0101
0102
0103
0104
0105 template<class T, class... Args>
0106 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0107 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0108 make_unique(BOOST_FWD_REF(Args)... args)
0109 { return unique_ptr<T>(new T(::boost::forward<Args>(args)...)); }
0110
0111
0112
0113
0114 template<class T, class... Args>
0115 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0116 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0117 make_unique_nothrow(BOOST_FWD_REF(Args)... args)
0118 { return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T(::boost::forward<Args>(args)...)); }
0119
0120 #else
0121 #define BOOST_MOVE_MAKE_UNIQUE_CODE(N)\
0122 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
0123 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
0124 make_unique( BOOST_MOVE_UREF##N)\
0125 { return unique_ptr<T>( new T( BOOST_MOVE_FWD##N ) ); }\
0126 \
0127 template<class T BOOST_MOVE_I##N BOOST_MOVE_CLASS##N>\
0128 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array\
0129 make_unique_nothrow( BOOST_MOVE_UREF##N)\
0130 { return unique_ptr<T>( new (*boost::move_upmu::nothrow_holder<>::pnothrow)T ( BOOST_MOVE_FWD##N ) ); }\
0131
0132 BOOST_MOVE_ITERATE_0TO9(BOOST_MOVE_MAKE_UNIQUE_CODE)
0133 #undef BOOST_MOVE_MAKE_UNIQUE_CODE
0134
0135 #endif
0136
0137
0138
0139
0140 template<class T>
0141 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0142 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0143 make_unique_definit()
0144 {
0145 return unique_ptr<T>(new T);
0146 }
0147
0148
0149
0150
0151 template<class T>
0152 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0153 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_not_array)
0154 make_unique_nothrow_definit()
0155 {
0156 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)T);
0157 }
0158
0159
0160
0161
0162
0163 template<class T>
0164 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0165 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0166 make_unique(std::size_t n)
0167 {
0168 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0169 return unique_ptr<T>(new U[n]());
0170 }
0171
0172
0173
0174
0175
0176 template<class T>
0177 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0178 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0179 make_unique_nothrow(std::size_t n)
0180 {
0181 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0182 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow)U[n]());
0183 }
0184
0185
0186
0187
0188
0189 template<class T>
0190 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0191 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0192 make_unique_definit(std::size_t n)
0193 {
0194 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0195 return unique_ptr<T>(new U[n]);
0196 }
0197
0198
0199
0200
0201
0202 template<class T>
0203 inline BOOST_MOVE_DOC1ST(unique_ptr<T>,
0204 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_unknown_bound)
0205 make_unique_nothrow_definit(std::size_t n)
0206 {
0207 typedef typename ::boost::move_upmu::remove_extent<T>::type U;
0208 return unique_ptr<T>(new (*boost::move_upmu::nothrow_holder<>::pnothrow) U[n]);
0209 }
0210
0211 #if !defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
0212
0213
0214
0215 template<class T, class... Args>
0216 inline BOOST_MOVE_DOC1ST(unspecified,
0217 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0218 make_unique(BOOST_FWD_REF(Args) ...) = delete;
0219
0220
0221
0222 template<class T, class... Args>
0223 inline BOOST_MOVE_DOC1ST(unspecified,
0224 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0225 make_unique_definit(BOOST_FWD_REF(Args) ...) = delete;
0226
0227
0228
0229 template<class T, class... Args>
0230 inline BOOST_MOVE_DOC1ST(unspecified,
0231 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0232 make_unique_nothrow(BOOST_FWD_REF(Args) ...) = delete;
0233
0234
0235
0236 template<class T, class... Args>
0237 inline BOOST_MOVE_DOC1ST(unspecified,
0238 typename ::boost::move_upmu::unique_ptr_if<T>::t_is_array_of_known_bound)
0239 make_unique_nothrow_definit(BOOST_FWD_REF(Args) ...) = delete;
0240
0241 #endif
0242
0243 }
0244
0245 }
0246
0247 #include <boost/move/detail/config_end.hpp>
0248
0249 #endif