Ticket #2481: make_shared_access.patch
File make_shared_access.patch, 24.7 KB (added by , 14 years ago) |
---|
-
make_shared.hpp
88 88 89 89 } // namespace detail 90 90 91 // Zero-argument versions 92 // 93 // Used even when variadic templates are available because of the new T() vs new T issue 94 95 template< class T > boost::shared_ptr< T > make_shared() 91 namespace detail 96 92 { 97 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 93 class make_shared_access 94 { 95 public: 98 96 99 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 97 template< class T > 98 static boost::shared_ptr< T > make_shared() 99 { 100 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 100 101 101 void * pv = pd->address();102 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 102 103 103 new( pv ) T(); 104 pd->set_initialized(); 104 void * pv = pd->address(); 105 105 106 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ));107 } 106 new( pv ) T(); 107 pd->set_initialized(); 108 108 109 template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a ) 110 { 111 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 109 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 110 } 112 111 113 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 112 template< class T, class A > 113 static boost::shared_ptr< T > allocate_shared( A const & a ) 114 { 115 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 114 116 115 void * pv = pd->address();117 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 116 118 117 new( pv ) T(); 118 pd->set_initialized(); 119 void * pv = pd->address(); 119 120 120 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 121 new( pv ) T(); 122 pd->set_initialized(); 123 124 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 125 } 126 127 #if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS ) 128 /// @todo implement var args version 129 #else 130 template< class T, class A1 > 131 static boost::shared_ptr< T > make_shared( A1 const & a1 ) 132 { 133 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 134 135 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 136 137 void * pv = pd->address(); 138 139 new( pv ) T( a1 ); 140 pd->set_initialized(); 141 142 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 143 } 144 145 template< class T, class A, class A1 > 146 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 ) 147 { 148 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 149 150 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 151 152 void * pv = pd->address(); 153 154 new( pv ) T( a1 ); 155 pd->set_initialized(); 156 157 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 158 } 159 160 template< class T, class A1, class A2 > 161 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 ) 162 { 163 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 164 165 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 166 167 void * pv = pd->address(); 168 169 new( pv ) T( a1, a2 ); 170 pd->set_initialized(); 171 172 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 173 } 174 175 template< class T, class A, class A1, class A2 > 176 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) 177 { 178 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 179 180 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 181 182 void * pv = pd->address(); 183 184 new( pv ) T( a1, a2 ); 185 pd->set_initialized(); 186 187 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 188 } 189 190 template< class T, class A1, class A2, class A3 > 191 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) 192 { 193 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 194 195 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 196 197 void * pv = pd->address(); 198 199 new( pv ) T( a1, a2, a3 ); 200 pd->set_initialized(); 201 202 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 203 } 204 205 template< class T, class A, class A1, class A2, class A3 > 206 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) 207 { 208 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 209 210 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 211 212 void * pv = pd->address(); 213 214 new( pv ) T( a1, a2, a3 ); 215 pd->set_initialized(); 216 217 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 218 } 219 220 template< class T, class A1, class A2, class A3, class A4 > 221 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) 222 { 223 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 224 225 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 226 227 void * pv = pd->address(); 228 229 new( pv ) T( a1, a2, a3, a4 ); 230 pd->set_initialized(); 231 232 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 233 } 234 235 template< class T, class A, class A1, class A2, class A3, class A4 > 236 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) 237 { 238 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 239 240 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 241 242 void * pv = pd->address(); 243 244 new( pv ) T( a1, a2, a3, a4 ); 245 pd->set_initialized(); 246 247 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 248 } 249 250 template< class T, class A1, class A2, class A3, class A4, class A5 > 251 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) 252 { 253 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 254 255 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 256 257 void * pv = pd->address(); 258 259 new( pv ) T( a1, a2, a3, a4, a5 ); 260 pd->set_initialized(); 261 262 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 263 } 264 265 template< class T, class A, class A1, class A2, class A3, class A4, class A5 > 266 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) 267 { 268 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 269 270 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 271 272 void * pv = pd->address(); 273 274 new( pv ) T( a1, a2, a3, a4, a5 ); 275 pd->set_initialized(); 276 277 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 278 } 279 280 template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > 281 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) 282 { 283 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 284 285 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 286 287 void * pv = pd->address(); 288 289 new( pv ) T( a1, a2, a3, a4, a5, a6 ); 290 pd->set_initialized(); 291 292 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 293 } 294 295 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > 296 static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) 297 { 298 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 299 300 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 301 302 void * pv = pd->address(); 303 304 new( pv ) T( a1, a2, a3, a4, a5, a6 ); 305 pd->set_initialized(); 306 307 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 308 } 309 310 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 311 static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) 312 { 313 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 314 315 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 316 317 void * pv = pd->address(); 318 319 new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); 320 pd->set_initialized(); 321 322 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 323 } 324 325 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 326 static boost::shared_ptr< T > 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 ) 327 { 328 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 329 330 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 331 332 void * pv = pd->address(); 333 334 new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); 335 pd->set_initialized(); 336 337 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 338 } 339 340 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 341 static boost::shared_ptr< T > 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 ) 342 { 343 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 344 345 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 346 347 void * pv = pd->address(); 348 349 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); 350 pd->set_initialized(); 351 352 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 353 } 354 355 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 356 static boost::shared_ptr< T > 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 ) 357 { 358 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 359 360 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 361 362 void * pv = pd->address(); 363 364 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); 365 pd->set_initialized(); 366 367 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 368 } 369 370 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 371 static boost::shared_ptr< T > 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 ) 372 { 373 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 374 375 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 376 377 void * pv = pd->address(); 378 379 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); 380 pd->set_initialized(); 381 382 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 383 } 384 385 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 386 static boost::shared_ptr< T > 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 ) 387 { 388 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 389 390 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 391 392 void * pv = pd->address(); 393 394 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); 395 pd->set_initialized(); 396 397 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 398 } 399 #endif 400 }; 401 } // namespace detail 402 403 // Zero-argument versions 404 // 405 // Used even when variadic templates are available because of the new T() vs new T issue 406 407 template< class T > boost::shared_ptr< T > make_shared() 408 { 409 return detail::make_shared_access::make_shared<T>(); 121 410 } 122 411 412 template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a ) 413 { 414 return detail::make_shared_access::allocate_shared<T>(); 415 } 416 123 417 #if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS ) 124 418 125 419 // Variadic templates, rvalue reference … … 159 453 template< class T, class A1 > 160 454 boost::shared_ptr< T > make_shared( A1 const & a1 ) 161 455 { 162 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 163 164 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 165 166 void * pv = pd->address(); 167 168 new( pv ) T( a1 ); 169 pd->set_initialized(); 170 171 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 456 return detail::make_shared_access::make_shared<T>(a1); 172 457 } 173 458 174 459 template< class T, class A, class A1 > 175 460 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 ) 176 461 { 177 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 178 179 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 180 181 void * pv = pd->address(); 182 183 new( pv ) T( a1 ); 184 pd->set_initialized(); 185 186 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 462 return detail::make_shared_access::allocate_shared<T>(a,a1); 187 463 } 188 464 189 465 template< class T, class A1, class A2 > 190 466 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 ) 191 467 { 192 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 193 194 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 195 196 void * pv = pd->address(); 197 198 new( pv ) T( a1, a2 ); 199 pd->set_initialized(); 200 201 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 468 return detail::make_shared_access::make_shared<T>(a1,a2); 202 469 } 203 470 204 471 template< class T, class A, class A1, class A2 > 205 472 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) 206 473 { 207 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 208 209 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 210 211 void * pv = pd->address(); 212 213 new( pv ) T( a1, a2 ); 214 pd->set_initialized(); 215 216 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 474 return detail::make_shared_access::allocate_shared<T>(a,a1,a2); 217 475 } 218 476 219 477 template< class T, class A1, class A2, class A3 > 220 478 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) 221 479 { 222 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 223 224 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 225 226 void * pv = pd->address(); 227 228 new( pv ) T( a1, a2, a3 ); 229 pd->set_initialized(); 230 231 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 480 return detail::make_shared_access::make_shared<T>(a1,a2,a3); 232 481 } 233 482 234 483 template< class T, class A, class A1, class A2, class A3 > 235 484 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) 236 485 { 237 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 238 239 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 240 241 void * pv = pd->address(); 242 243 new( pv ) T( a1, a2, a3 ); 244 pd->set_initialized(); 245 246 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 486 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3); 247 487 } 248 488 249 489 template< class T, class A1, class A2, class A3, class A4 > 250 490 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) 251 491 { 252 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 253 254 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 255 256 void * pv = pd->address(); 257 258 new( pv ) T( a1, a2, a3, a4 ); 259 pd->set_initialized(); 260 261 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 492 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4); 262 493 } 263 494 264 495 template< class T, class A, class A1, class A2, class A3, class A4 > 265 496 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) 266 497 { 267 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 268 269 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 270 271 void * pv = pd->address(); 272 273 new( pv ) T( a1, a2, a3, a4 ); 274 pd->set_initialized(); 275 276 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 498 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4); 277 499 } 278 500 279 501 template< class T, class A1, class A2, class A3, class A4, class A5 > 280 502 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) 281 503 { 282 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 283 284 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 285 286 void * pv = pd->address(); 287 288 new( pv ) T( a1, a2, a3, a4, a5 ); 289 pd->set_initialized(); 290 291 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 504 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5); 292 505 } 293 506 294 507 template< class T, class A, class A1, class A2, class A3, class A4, class A5 > 295 508 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) 296 509 { 297 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 298 299 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 300 301 void * pv = pd->address(); 302 303 new( pv ) T( a1, a2, a3, a4, a5 ); 304 pd->set_initialized(); 305 306 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 510 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5); 307 511 } 308 512 309 513 template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > 310 514 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) 311 515 { 312 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 313 314 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 315 316 void * pv = pd->address(); 317 318 new( pv ) T( a1, a2, a3, a4, a5, a6 ); 319 pd->set_initialized(); 320 321 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 516 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6); 322 517 } 323 518 324 519 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > 325 520 boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) 326 521 { 327 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 328 329 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 330 331 void * pv = pd->address(); 332 333 new( pv ) T( a1, a2, a3, a4, a5, a6 ); 334 pd->set_initialized(); 335 336 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 522 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6); 337 523 } 338 524 339 525 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 340 526 boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6, A7 const & a7 ) 341 527 { 342 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 343 344 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 345 346 void * pv = pd->address(); 347 348 new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); 349 pd->set_initialized(); 350 351 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 528 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7); 352 529 } 353 530 354 531 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 355 532 boost::shared_ptr< T > 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 ) 356 533 { 357 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 358 359 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 360 361 void * pv = pd->address(); 362 363 new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); 364 pd->set_initialized(); 365 366 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 534 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7); 367 535 } 368 536 369 537 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 370 538 boost::shared_ptr< T > 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 ) 371 539 { 372 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 373 374 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 375 376 void * pv = pd->address(); 377 378 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); 379 pd->set_initialized(); 380 381 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 540 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7,a8); 382 541 } 383 542 384 543 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 385 544 boost::shared_ptr< T > 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 ) 386 545 { 387 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 388 389 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 390 391 void * pv = pd->address(); 392 393 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); 394 pd->set_initialized(); 395 396 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 546 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7,a8); 397 547 } 398 548 399 549 template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 400 550 boost::shared_ptr< T > 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 ) 401 551 { 402 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); 403 404 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); 405 406 void * pv = pd->address(); 407 408 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); 409 pd->set_initialized(); 410 411 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); 552 return detail::make_shared_access::make_shared<T>(a1,a2,a3,a4,a5,a6,a7,a8,a9); 412 553 } 413 554 414 555 template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 415 556 boost::shared_ptr< T > 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 ) 416 557 { 417 boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); 558 return detail::make_shared_access::allocate_shared<T>(a,a1,a2,a3,a4,a5,a6,a7,a8,a9); 559 } 418 560 419 detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );561 using detail::make_shared_access; 420 562 421 void * pv = pd->address();422 423 new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 );424 pd->set_initialized();425 426 return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) );427 }428 429 563 #endif 430 564 431 565 } // namespace boost