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