Jeff Thompson | f7d4994 | 2013-08-01 16:47:40 -0700 | [diff] [blame^] | 1 | #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED |
| 2 | #define BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED |
| 3 | |
| 4 | // make_shared_object.hpp |
| 5 | // |
| 6 | // Copyright (c) 2007, 2008, 2012 Peter Dimov |
| 7 | // |
| 8 | // Distributed under the Boost Software License, Version 1.0. |
| 9 | // See accompanying file LICENSE_1_0.txt or copy at |
| 10 | // http://www.boost.org/LICENSE_1_0.txt |
| 11 | // |
| 12 | // See http://www.boost.org/libs/smart_ptr/make_shared.html |
| 13 | // for documentation. |
| 14 | |
| 15 | #include <boost/config.hpp> |
| 16 | #include <boost/smart_ptr/shared_ptr.hpp> |
| 17 | #include <boost/smart_ptr/detail/sp_forward.hpp> |
| 18 | #include <boost/type_traits/type_with_alignment.hpp> |
| 19 | #include <boost/type_traits/alignment_of.hpp> |
| 20 | #include <cstddef> |
| 21 | #include <new> |
| 22 | |
| 23 | namespace ndnboost |
| 24 | { |
| 25 | |
| 26 | namespace detail |
| 27 | { |
| 28 | |
| 29 | template< std::size_t N, std::size_t A > struct sp_aligned_storage |
| 30 | { |
| 31 | union type |
| 32 | { |
| 33 | char data_[ N ]; |
| 34 | typename ndnboost::type_with_alignment< A >::type align_; |
| 35 | }; |
| 36 | }; |
| 37 | |
| 38 | template< class T > class sp_ms_deleter |
| 39 | { |
| 40 | private: |
| 41 | |
| 42 | typedef typename sp_aligned_storage< sizeof( T ), ::ndnboost::alignment_of< T >::value >::type storage_type; |
| 43 | |
| 44 | bool initialized_; |
| 45 | storage_type storage_; |
| 46 | |
| 47 | private: |
| 48 | |
| 49 | void destroy() |
| 50 | { |
| 51 | if( initialized_ ) |
| 52 | { |
| 53 | #if defined( __GNUC__ ) |
| 54 | |
| 55 | // fixes incorrect aliasing warning |
| 56 | T * p = reinterpret_cast< T* >( storage_.data_ ); |
| 57 | p->~T(); |
| 58 | |
| 59 | #else |
| 60 | |
| 61 | reinterpret_cast< T* >( storage_.data_ )->~T(); |
| 62 | |
| 63 | #endif |
| 64 | |
| 65 | initialized_ = false; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | public: |
| 70 | |
| 71 | sp_ms_deleter() BOOST_NOEXCEPT : initialized_( false ) |
| 72 | { |
| 73 | } |
| 74 | |
| 75 | // optimization: do not copy storage_ |
| 76 | sp_ms_deleter( sp_ms_deleter const & ) BOOST_NOEXCEPT : initialized_( false ) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | ~sp_ms_deleter() |
| 81 | { |
| 82 | destroy(); |
| 83 | } |
| 84 | |
| 85 | void operator()( T * ) |
| 86 | { |
| 87 | destroy(); |
| 88 | } |
| 89 | |
| 90 | void * address() BOOST_NOEXCEPT |
| 91 | { |
| 92 | return storage_.data_; |
| 93 | } |
| 94 | |
| 95 | void set_initialized() BOOST_NOEXCEPT |
| 96 | { |
| 97 | initialized_ = true; |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | template< class T > struct sp_if_not_array |
| 102 | { |
| 103 | typedef ndnboost::shared_ptr< T > type; |
| 104 | }; |
| 105 | |
| 106 | #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION ) |
| 107 | |
| 108 | template< class T > struct sp_if_not_array< T[] > |
| 109 | { |
| 110 | }; |
| 111 | |
| 112 | #if !defined( __BORLANDC__ ) || !BOOST_WORKAROUND( __BORLANDC__, < 0x600 ) |
| 113 | |
| 114 | template< class T, std::size_t N > struct sp_if_not_array< T[N] > |
| 115 | { |
| 116 | }; |
| 117 | |
| 118 | #endif |
| 119 | |
| 120 | #endif |
| 121 | |
| 122 | } // namespace detail |
| 123 | |
| 124 | #if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING ) |
| 125 | # define BOOST_SP_MSD( T ) ndnboost::detail::sp_inplace_tag< ndnboost::detail::sp_ms_deleter< T > >() |
| 126 | #else |
| 127 | # define BOOST_SP_MSD( T ) ndnboost::detail::sp_ms_deleter< T >() |
| 128 | #endif |
| 129 | |
| 130 | // Zero-argument versions |
| 131 | // |
| 132 | // Used even when variadic templates are available because of the new T() vs new T issue |
| 133 | |
| 134 | template< class T > typename ndnboost::detail::sp_if_not_array< T >::type make_shared() |
| 135 | { |
| 136 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 137 | |
| 138 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 139 | |
| 140 | void * pv = pd->address(); |
| 141 | |
| 142 | ::new( pv ) T(); |
| 143 | pd->set_initialized(); |
| 144 | |
| 145 | T * pt2 = static_cast< T* >( pv ); |
| 146 | |
| 147 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 148 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 149 | } |
| 150 | |
| 151 | template< class T > typename ndnboost::detail::sp_if_not_array< T >::type make_shared_noinit() |
| 152 | { |
| 153 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 154 | |
| 155 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 156 | |
| 157 | void * pv = pd->address(); |
| 158 | |
| 159 | ::new( pv ) T; |
| 160 | pd->set_initialized(); |
| 161 | |
| 162 | T * pt2 = static_cast< T* >( pv ); |
| 163 | |
| 164 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 165 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 166 | } |
| 167 | |
| 168 | template< class T, class A > typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a ) |
| 169 | { |
| 170 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 171 | |
| 172 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 173 | |
| 174 | void * pv = pd->address(); |
| 175 | |
| 176 | ::new( pv ) T(); |
| 177 | pd->set_initialized(); |
| 178 | |
| 179 | T * pt2 = static_cast< T* >( pv ); |
| 180 | |
| 181 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 182 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 183 | } |
| 184 | |
| 185 | template< class T, class A > typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared_noinit( A const & a ) |
| 186 | { |
| 187 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 188 | |
| 189 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 190 | |
| 191 | void * pv = pd->address(); |
| 192 | |
| 193 | ::new( pv ) T; |
| 194 | pd->set_initialized(); |
| 195 | |
| 196 | T * pt2 = static_cast< T* >( pv ); |
| 197 | |
| 198 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 199 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 200 | } |
| 201 | |
| 202 | #if !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) |
| 203 | |
| 204 | // Variadic templates, rvalue reference |
| 205 | |
| 206 | template< class T, class Arg1, class... Args > typename ndnboost::detail::sp_if_not_array< T >::type make_shared( Arg1 && arg1, Args && ... args ) |
| 207 | { |
| 208 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 209 | |
| 210 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 211 | |
| 212 | void * pv = pd->address(); |
| 213 | |
| 214 | ::new( pv ) T( ndnboost::detail::sp_forward<Arg1>( arg1 ), ndnboost::detail::sp_forward<Args>( args )... ); |
| 215 | pd->set_initialized(); |
| 216 | |
| 217 | T * pt2 = static_cast< T* >( pv ); |
| 218 | |
| 219 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 220 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 221 | } |
| 222 | |
| 223 | template< class T, class A, class Arg1, class... Args > typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, Arg1 && arg1, Args && ... args ) |
| 224 | { |
| 225 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 226 | |
| 227 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 228 | |
| 229 | void * pv = pd->address(); |
| 230 | |
| 231 | ::new( pv ) T( ndnboost::detail::sp_forward<Arg1>( arg1 ), ndnboost::detail::sp_forward<Args>( args )... ); |
| 232 | pd->set_initialized(); |
| 233 | |
| 234 | T * pt2 = static_cast< T* >( pv ); |
| 235 | |
| 236 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 237 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 238 | } |
| 239 | |
| 240 | #elif !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) |
| 241 | |
| 242 | // For example MSVC 10.0 |
| 243 | |
| 244 | template< class T, class A1 > |
| 245 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1 ) |
| 246 | { |
| 247 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 248 | |
| 249 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 250 | |
| 251 | void * pv = pd->address(); |
| 252 | |
| 253 | ::new( pv ) T( |
| 254 | ndnboost::detail::sp_forward<A1>( a1 ) |
| 255 | ); |
| 256 | |
| 257 | pd->set_initialized(); |
| 258 | |
| 259 | T * pt2 = static_cast< T* >( pv ); |
| 260 | |
| 261 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 262 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 263 | } |
| 264 | |
| 265 | template< class T, class A, class A1 > |
| 266 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1 ) |
| 267 | { |
| 268 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 269 | |
| 270 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 271 | |
| 272 | void * pv = pd->address(); |
| 273 | |
| 274 | ::new( pv ) T( |
| 275 | ndnboost::detail::sp_forward<A1>( a1 ) |
| 276 | ); |
| 277 | |
| 278 | pd->set_initialized(); |
| 279 | |
| 280 | T * pt2 = static_cast< T* >( pv ); |
| 281 | |
| 282 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 283 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 284 | } |
| 285 | |
| 286 | template< class T, class A1, class A2 > |
| 287 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2 ) |
| 288 | { |
| 289 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 290 | |
| 291 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 292 | |
| 293 | void * pv = pd->address(); |
| 294 | |
| 295 | ::new( pv ) T( |
| 296 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 297 | ndnboost::detail::sp_forward<A2>( a2 ) |
| 298 | ); |
| 299 | |
| 300 | pd->set_initialized(); |
| 301 | |
| 302 | T * pt2 = static_cast< T* >( pv ); |
| 303 | |
| 304 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 305 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 306 | } |
| 307 | |
| 308 | template< class T, class A, class A1, class A2 > |
| 309 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2 ) |
| 310 | { |
| 311 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 312 | |
| 313 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 314 | |
| 315 | void * pv = pd->address(); |
| 316 | |
| 317 | ::new( pv ) T( |
| 318 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 319 | ndnboost::detail::sp_forward<A2>( a2 ) |
| 320 | ); |
| 321 | |
| 322 | pd->set_initialized(); |
| 323 | |
| 324 | T * pt2 = static_cast< T* >( pv ); |
| 325 | |
| 326 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 327 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 328 | } |
| 329 | |
| 330 | template< class T, class A1, class A2, class A3 > |
| 331 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3 ) |
| 332 | { |
| 333 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 334 | |
| 335 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 336 | |
| 337 | void * pv = pd->address(); |
| 338 | |
| 339 | ::new( pv ) T( |
| 340 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 341 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 342 | ndnboost::detail::sp_forward<A3>( a3 ) |
| 343 | ); |
| 344 | |
| 345 | pd->set_initialized(); |
| 346 | |
| 347 | T * pt2 = static_cast< T* >( pv ); |
| 348 | |
| 349 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 350 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 351 | } |
| 352 | |
| 353 | template< class T, class A, class A1, class A2, class A3 > |
| 354 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3 ) |
| 355 | { |
| 356 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 357 | |
| 358 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 359 | |
| 360 | void * pv = pd->address(); |
| 361 | |
| 362 | ::new( pv ) T( |
| 363 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 364 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 365 | ndnboost::detail::sp_forward<A3>( a3 ) |
| 366 | ); |
| 367 | |
| 368 | pd->set_initialized(); |
| 369 | |
| 370 | T * pt2 = static_cast< T* >( pv ); |
| 371 | |
| 372 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 373 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 374 | } |
| 375 | |
| 376 | template< class T, class A1, class A2, class A3, class A4 > |
| 377 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) |
| 378 | { |
| 379 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 380 | |
| 381 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 382 | |
| 383 | void * pv = pd->address(); |
| 384 | |
| 385 | ::new( pv ) T( |
| 386 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 387 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 388 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 389 | ndnboost::detail::sp_forward<A4>( a4 ) |
| 390 | ); |
| 391 | |
| 392 | pd->set_initialized(); |
| 393 | |
| 394 | T * pt2 = static_cast< T* >( pv ); |
| 395 | |
| 396 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 397 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 398 | } |
| 399 | |
| 400 | template< class T, class A, class A1, class A2, class A3, class A4 > |
| 401 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4 ) |
| 402 | { |
| 403 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 404 | |
| 405 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 406 | |
| 407 | void * pv = pd->address(); |
| 408 | |
| 409 | ::new( pv ) T( |
| 410 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 411 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 412 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 413 | ndnboost::detail::sp_forward<A4>( a4 ) |
| 414 | ); |
| 415 | |
| 416 | pd->set_initialized(); |
| 417 | |
| 418 | T * pt2 = static_cast< T* >( pv ); |
| 419 | |
| 420 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 421 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 422 | } |
| 423 | |
| 424 | template< class T, class A1, class A2, class A3, class A4, class A5 > |
| 425 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) |
| 426 | { |
| 427 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 428 | |
| 429 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 430 | |
| 431 | void * pv = pd->address(); |
| 432 | |
| 433 | ::new( pv ) T( |
| 434 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 435 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 436 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 437 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 438 | ndnboost::detail::sp_forward<A5>( a5 ) |
| 439 | ); |
| 440 | |
| 441 | pd->set_initialized(); |
| 442 | |
| 443 | T * pt2 = static_cast< T* >( pv ); |
| 444 | |
| 445 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 446 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 447 | } |
| 448 | |
| 449 | template< class T, class A, class A1, class A2, class A3, class A4, class A5 > |
| 450 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5 ) |
| 451 | { |
| 452 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 453 | |
| 454 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 455 | |
| 456 | void * pv = pd->address(); |
| 457 | |
| 458 | ::new( pv ) T( |
| 459 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 460 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 461 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 462 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 463 | ndnboost::detail::sp_forward<A5>( a5 ) |
| 464 | ); |
| 465 | |
| 466 | pd->set_initialized(); |
| 467 | |
| 468 | T * pt2 = static_cast< T* >( pv ); |
| 469 | |
| 470 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 471 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 472 | } |
| 473 | |
| 474 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > |
| 475 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) |
| 476 | { |
| 477 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 478 | |
| 479 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 480 | |
| 481 | void * pv = pd->address(); |
| 482 | |
| 483 | ::new( pv ) T( |
| 484 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 485 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 486 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 487 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 488 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 489 | ndnboost::detail::sp_forward<A6>( a6 ) |
| 490 | ); |
| 491 | |
| 492 | pd->set_initialized(); |
| 493 | |
| 494 | T * pt2 = static_cast< T* >( pv ); |
| 495 | |
| 496 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 497 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 498 | } |
| 499 | |
| 500 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > |
| 501 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6 ) |
| 502 | { |
| 503 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 504 | |
| 505 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 506 | |
| 507 | void * pv = pd->address(); |
| 508 | |
| 509 | ::new( pv ) T( |
| 510 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 511 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 512 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 513 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 514 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 515 | ndnboost::detail::sp_forward<A6>( a6 ) |
| 516 | ); |
| 517 | |
| 518 | pd->set_initialized(); |
| 519 | |
| 520 | T * pt2 = static_cast< T* >( pv ); |
| 521 | |
| 522 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 523 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 524 | } |
| 525 | |
| 526 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > |
| 527 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) |
| 528 | { |
| 529 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 530 | |
| 531 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 532 | |
| 533 | void * pv = pd->address(); |
| 534 | |
| 535 | ::new( pv ) T( |
| 536 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 537 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 538 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 539 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 540 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 541 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 542 | ndnboost::detail::sp_forward<A7>( a7 ) |
| 543 | ); |
| 544 | |
| 545 | pd->set_initialized(); |
| 546 | |
| 547 | T * pt2 = static_cast< T* >( pv ); |
| 548 | |
| 549 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 550 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 551 | } |
| 552 | |
| 553 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > |
| 554 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7 ) |
| 555 | { |
| 556 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 557 | |
| 558 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 559 | |
| 560 | void * pv = pd->address(); |
| 561 | |
| 562 | ::new( pv ) T( |
| 563 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 564 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 565 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 566 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 567 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 568 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 569 | ndnboost::detail::sp_forward<A7>( a7 ) |
| 570 | ); |
| 571 | |
| 572 | pd->set_initialized(); |
| 573 | |
| 574 | T * pt2 = static_cast< T* >( pv ); |
| 575 | |
| 576 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 577 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 578 | } |
| 579 | |
| 580 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > |
| 581 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) |
| 582 | { |
| 583 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 584 | |
| 585 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 586 | |
| 587 | void * pv = pd->address(); |
| 588 | |
| 589 | ::new( pv ) T( |
| 590 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 591 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 592 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 593 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 594 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 595 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 596 | ndnboost::detail::sp_forward<A7>( a7 ), |
| 597 | ndnboost::detail::sp_forward<A8>( a8 ) |
| 598 | ); |
| 599 | |
| 600 | pd->set_initialized(); |
| 601 | |
| 602 | T * pt2 = static_cast< T* >( pv ); |
| 603 | |
| 604 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 605 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 606 | } |
| 607 | |
| 608 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > |
| 609 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8 ) |
| 610 | { |
| 611 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 612 | |
| 613 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 614 | |
| 615 | void * pv = pd->address(); |
| 616 | |
| 617 | ::new( pv ) T( |
| 618 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 619 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 620 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 621 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 622 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 623 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 624 | ndnboost::detail::sp_forward<A7>( a7 ), |
| 625 | ndnboost::detail::sp_forward<A8>( a8 ) |
| 626 | ); |
| 627 | |
| 628 | pd->set_initialized(); |
| 629 | |
| 630 | T * pt2 = static_cast< T* >( pv ); |
| 631 | |
| 632 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 633 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 634 | } |
| 635 | |
| 636 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > |
| 637 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) |
| 638 | { |
| 639 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 640 | |
| 641 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 642 | |
| 643 | void * pv = pd->address(); |
| 644 | |
| 645 | ::new( pv ) T( |
| 646 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 647 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 648 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 649 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 650 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 651 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 652 | ndnboost::detail::sp_forward<A7>( a7 ), |
| 653 | ndnboost::detail::sp_forward<A8>( a8 ), |
| 654 | ndnboost::detail::sp_forward<A9>( a9 ) |
| 655 | ); |
| 656 | |
| 657 | pd->set_initialized(); |
| 658 | |
| 659 | T * pt2 = static_cast< T* >( pv ); |
| 660 | |
| 661 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 662 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 663 | } |
| 664 | |
| 665 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > |
| 666 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9 ) |
| 667 | { |
| 668 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 669 | |
| 670 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 671 | |
| 672 | void * pv = pd->address(); |
| 673 | |
| 674 | ::new( pv ) T( |
| 675 | ndnboost::detail::sp_forward<A1>( a1 ), |
| 676 | ndnboost::detail::sp_forward<A2>( a2 ), |
| 677 | ndnboost::detail::sp_forward<A3>( a3 ), |
| 678 | ndnboost::detail::sp_forward<A4>( a4 ), |
| 679 | ndnboost::detail::sp_forward<A5>( a5 ), |
| 680 | ndnboost::detail::sp_forward<A6>( a6 ), |
| 681 | ndnboost::detail::sp_forward<A7>( a7 ), |
| 682 | ndnboost::detail::sp_forward<A8>( a8 ), |
| 683 | ndnboost::detail::sp_forward<A9>( a9 ) |
| 684 | ); |
| 685 | |
| 686 | pd->set_initialized(); |
| 687 | |
| 688 | T * pt2 = static_cast< T* >( pv ); |
| 689 | |
| 690 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 691 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 692 | } |
| 693 | |
| 694 | #else |
| 695 | |
| 696 | // C++03 version |
| 697 | |
| 698 | template< class T, class A1 > |
| 699 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1 ) |
| 700 | { |
| 701 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 702 | |
| 703 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 704 | |
| 705 | void * pv = pd->address(); |
| 706 | |
| 707 | ::new( pv ) T( a1 ); |
| 708 | pd->set_initialized(); |
| 709 | |
| 710 | T * pt2 = static_cast< T* >( pv ); |
| 711 | |
| 712 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 713 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 714 | } |
| 715 | |
| 716 | template< class T, class A, class A1 > |
| 717 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1 ) |
| 718 | { |
| 719 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 720 | |
| 721 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 722 | |
| 723 | void * pv = pd->address(); |
| 724 | |
| 725 | ::new( pv ) T( a1 ); |
| 726 | pd->set_initialized(); |
| 727 | |
| 728 | T * pt2 = static_cast< T* >( pv ); |
| 729 | |
| 730 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 731 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 732 | } |
| 733 | |
| 734 | template< class T, class A1, class A2 > |
| 735 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2 ) |
| 736 | { |
| 737 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 738 | |
| 739 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 740 | |
| 741 | void * pv = pd->address(); |
| 742 | |
| 743 | ::new( pv ) T( a1, a2 ); |
| 744 | pd->set_initialized(); |
| 745 | |
| 746 | T * pt2 = static_cast< T* >( pv ); |
| 747 | |
| 748 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 749 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 750 | } |
| 751 | |
| 752 | template< class T, class A, class A1, class A2 > |
| 753 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) |
| 754 | { |
| 755 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 756 | |
| 757 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 758 | |
| 759 | void * pv = pd->address(); |
| 760 | |
| 761 | ::new( pv ) T( a1, a2 ); |
| 762 | pd->set_initialized(); |
| 763 | |
| 764 | T * pt2 = static_cast< T* >( pv ); |
| 765 | |
| 766 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 767 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 768 | } |
| 769 | |
| 770 | template< class T, class A1, class A2, class A3 > |
| 771 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) |
| 772 | { |
| 773 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 774 | |
| 775 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 776 | |
| 777 | void * pv = pd->address(); |
| 778 | |
| 779 | ::new( pv ) T( a1, a2, a3 ); |
| 780 | pd->set_initialized(); |
| 781 | |
| 782 | T * pt2 = static_cast< T* >( pv ); |
| 783 | |
| 784 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 785 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 786 | } |
| 787 | |
| 788 | template< class T, class A, class A1, class A2, class A3 > |
| 789 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) |
| 790 | { |
| 791 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 792 | |
| 793 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 794 | |
| 795 | void * pv = pd->address(); |
| 796 | |
| 797 | ::new( pv ) T( a1, a2, a3 ); |
| 798 | pd->set_initialized(); |
| 799 | |
| 800 | T * pt2 = static_cast< T* >( pv ); |
| 801 | |
| 802 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 803 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 804 | } |
| 805 | |
| 806 | template< class T, class A1, class A2, class A3, class A4 > |
| 807 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) |
| 808 | { |
| 809 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 810 | |
| 811 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 812 | |
| 813 | void * pv = pd->address(); |
| 814 | |
| 815 | ::new( pv ) T( a1, a2, a3, a4 ); |
| 816 | pd->set_initialized(); |
| 817 | |
| 818 | T * pt2 = static_cast< T* >( pv ); |
| 819 | |
| 820 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 821 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 822 | } |
| 823 | |
| 824 | template< class T, class A, class A1, class A2, class A3, class A4 > |
| 825 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) |
| 826 | { |
| 827 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 828 | |
| 829 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 830 | |
| 831 | void * pv = pd->address(); |
| 832 | |
| 833 | ::new( pv ) T( a1, a2, a3, a4 ); |
| 834 | pd->set_initialized(); |
| 835 | |
| 836 | T * pt2 = static_cast< T* >( pv ); |
| 837 | |
| 838 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 839 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 840 | } |
| 841 | |
| 842 | template< class T, class A1, class A2, class A3, class A4, class A5 > |
| 843 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) |
| 844 | { |
| 845 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 846 | |
| 847 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 848 | |
| 849 | void * pv = pd->address(); |
| 850 | |
| 851 | ::new( pv ) T( a1, a2, a3, a4, a5 ); |
| 852 | pd->set_initialized(); |
| 853 | |
| 854 | T * pt2 = static_cast< T* >( pv ); |
| 855 | |
| 856 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 857 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 858 | } |
| 859 | |
| 860 | template< class T, class A, class A1, class A2, class A3, class A4, class A5 > |
| 861 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) |
| 862 | { |
| 863 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 864 | |
| 865 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 866 | |
| 867 | void * pv = pd->address(); |
| 868 | |
| 869 | ::new( pv ) T( a1, a2, a3, a4, a5 ); |
| 870 | pd->set_initialized(); |
| 871 | |
| 872 | T * pt2 = static_cast< T* >( pv ); |
| 873 | |
| 874 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 875 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 876 | } |
| 877 | |
| 878 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > |
| 879 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) |
| 880 | { |
| 881 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 882 | |
| 883 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 884 | |
| 885 | void * pv = pd->address(); |
| 886 | |
| 887 | ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); |
| 888 | pd->set_initialized(); |
| 889 | |
| 890 | T * pt2 = static_cast< T* >( pv ); |
| 891 | |
| 892 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 893 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 894 | } |
| 895 | |
| 896 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > |
| 897 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) |
| 898 | { |
| 899 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 900 | |
| 901 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 902 | |
| 903 | void * pv = pd->address(); |
| 904 | |
| 905 | ::new( pv ) T( a1, a2, a3, a4, a5, a6 ); |
| 906 | pd->set_initialized(); |
| 907 | |
| 908 | T * pt2 = static_cast< T* >( pv ); |
| 909 | |
| 910 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 911 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 912 | } |
| 913 | |
| 914 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > |
| 915 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) |
| 916 | { |
| 917 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 918 | |
| 919 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 920 | |
| 921 | void * pv = pd->address(); |
| 922 | |
| 923 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); |
| 924 | pd->set_initialized(); |
| 925 | |
| 926 | T * pt2 = static_cast< T* >( pv ); |
| 927 | |
| 928 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 929 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 930 | } |
| 931 | |
| 932 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > |
| 933 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) |
| 934 | { |
| 935 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 936 | |
| 937 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 938 | |
| 939 | void * pv = pd->address(); |
| 940 | |
| 941 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); |
| 942 | pd->set_initialized(); |
| 943 | |
| 944 | T * pt2 = static_cast< T* >( pv ); |
| 945 | |
| 946 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 947 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 948 | } |
| 949 | |
| 950 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > |
| 951 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) |
| 952 | { |
| 953 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 954 | |
| 955 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 956 | |
| 957 | void * pv = pd->address(); |
| 958 | |
| 959 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); |
| 960 | pd->set_initialized(); |
| 961 | |
| 962 | T * pt2 = static_cast< T* >( pv ); |
| 963 | |
| 964 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 965 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 966 | } |
| 967 | |
| 968 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > |
| 969 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8 ) |
| 970 | { |
| 971 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 972 | |
| 973 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 974 | |
| 975 | void * pv = pd->address(); |
| 976 | |
| 977 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); |
| 978 | pd->set_initialized(); |
| 979 | |
| 980 | T * pt2 = static_cast< T* >( pv ); |
| 981 | |
| 982 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 983 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 984 | } |
| 985 | |
| 986 | template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > |
| 987 | typename ndnboost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) |
| 988 | { |
| 989 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); |
| 990 | |
| 991 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 992 | |
| 993 | void * pv = pd->address(); |
| 994 | |
| 995 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); |
| 996 | pd->set_initialized(); |
| 997 | |
| 998 | T * pt2 = static_cast< T* >( pv ); |
| 999 | |
| 1000 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 1001 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 1002 | } |
| 1003 | |
| 1004 | template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > |
| 1005 | typename ndnboost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7, A8 const & a8, A9 const & a9 ) |
| 1006 | { |
| 1007 | ndnboost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); |
| 1008 | |
| 1009 | ndnboost::detail::sp_ms_deleter< T > * pd = static_cast<ndnboost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() ); |
| 1010 | |
| 1011 | void * pv = pd->address(); |
| 1012 | |
| 1013 | ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); |
| 1014 | pd->set_initialized(); |
| 1015 | |
| 1016 | T * pt2 = static_cast< T* >( pv ); |
| 1017 | |
| 1018 | ndnboost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 ); |
| 1019 | return ndnboost::shared_ptr< T >( pt, pt2 ); |
| 1020 | } |
| 1021 | |
| 1022 | #endif |
| 1023 | |
| 1024 | #undef BOOST_SP_MSD |
| 1025 | |
| 1026 | } // namespace ndnboost |
| 1027 | |
| 1028 | #endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED |