123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802 |
- #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED
- #define BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED
- // make_shared_object.hpp
- //
- // Copyright (c) 2007, 2008, 2012 Peter Dimov
- //
- // Distributed under the Boost Software License, Version 1.0.
- // See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt
- //
- // See http://www.boost.org/libs/smart_ptr/ for documentation.
- #include <boost/smart_ptr/detail/requires_cxx11.hpp>
- #include <boost/config.hpp>
- #include <boost/move/core.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/smart_ptr/shared_ptr.hpp>
- #include <boost/smart_ptr/detail/sp_forward.hpp>
- #include <boost/smart_ptr/detail/sp_noexcept.hpp>
- #include <boost/type_traits/type_with_alignment.hpp>
- #include <boost/type_traits/alignment_of.hpp>
- #include <cstddef>
- #include <new>
- namespace boost
- {
- namespace detail
- {
- template< std::size_t N, std::size_t A > struct sp_aligned_storage
- {
- union type
- {
- char data_[ N ];
- typename boost::type_with_alignment< A >::type align_;
- };
- };
- template< class T > class sp_ms_deleter
- {
- private:
- typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
- bool initialized_;
- storage_type storage_;
- private:
- void destroy() BOOST_SP_NOEXCEPT
- {
- if( initialized_ )
- {
- #if defined( __GNUC__ )
- // fixes incorrect aliasing warning
- T * p = reinterpret_cast< T* >( storage_.data_ );
- p->~T();
- #else
- reinterpret_cast< T* >( storage_.data_ )->~T();
- #endif
- initialized_ = false;
- }
- }
- public:
- sp_ms_deleter() BOOST_SP_NOEXCEPT : initialized_( false )
- {
- }
- template<class A> explicit sp_ms_deleter( A const & ) BOOST_SP_NOEXCEPT : initialized_( false )
- {
- }
- // optimization: do not copy storage_
- sp_ms_deleter( sp_ms_deleter const & ) BOOST_SP_NOEXCEPT : initialized_( false )
- {
- }
- ~sp_ms_deleter() BOOST_SP_NOEXCEPT
- {
- destroy();
- }
- void operator()( T * ) BOOST_SP_NOEXCEPT
- {
- destroy();
- }
- static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
- {
- }
- void * address() BOOST_SP_NOEXCEPT
- {
- return storage_.data_;
- }
- void set_initialized() BOOST_SP_NOEXCEPT
- {
- initialized_ = true;
- }
- };
- template< class T, class A > class sp_as_deleter
- {
- private:
- typedef typename sp_aligned_storage< sizeof( T ), ::boost::alignment_of< T >::value >::type storage_type;
- storage_type storage_;
- A a_;
- bool initialized_;
- private:
- void destroy() BOOST_SP_NOEXCEPT
- {
- if( initialized_ )
- {
- T * p = reinterpret_cast< T* >( storage_.data_ );
- #if !defined( BOOST_NO_CXX11_ALLOCATOR )
- std::allocator_traits<A>::destroy( a_, p );
- #else
- p->~T();
- #endif
- initialized_ = false;
- }
- }
- public:
- sp_as_deleter( A const & a ) BOOST_SP_NOEXCEPT : a_( a ), initialized_( false )
- {
- }
- // optimization: do not copy storage_
- sp_as_deleter( sp_as_deleter const & r ) BOOST_SP_NOEXCEPT : a_( r.a_), initialized_( false )
- {
- }
- ~sp_as_deleter() BOOST_SP_NOEXCEPT
- {
- destroy();
- }
- void operator()( T * ) BOOST_SP_NOEXCEPT
- {
- destroy();
- }
- static void operator_fn( T* ) BOOST_SP_NOEXCEPT // operator() can't be static
- {
- }
- void * address() BOOST_SP_NOEXCEPT
- {
- return storage_.data_;
- }
- void set_initialized() BOOST_SP_NOEXCEPT
- {
- initialized_ = true;
- }
- };
- template< class T > struct sp_if_not_array
- {
- typedef boost::shared_ptr< T > type;
- };
- #if !defined( BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION )
- template< class T > struct sp_if_not_array< T[] >
- {
- };
- #if !defined( BOOST_BORLANDC ) || !BOOST_WORKAROUND( BOOST_BORLANDC, < 0x600 )
- template< class T, std::size_t N > struct sp_if_not_array< T[N] >
- {
- };
- #endif
- #endif
- } // namespace detail
- #if !defined( BOOST_NO_FUNCTION_TEMPLATE_ORDERING )
- # define BOOST_SP_MSD( T ) boost::detail::sp_inplace_tag< boost::detail::sp_ms_deleter< T > >()
- #else
- # define BOOST_SP_MSD( T ) boost::detail::sp_ms_deleter< T >()
- #endif
- // _noinit versions
- template< class T > typename boost::detail::sp_if_not_array< T >::type make_shared_noinit()
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T;
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A > typename boost::detail::sp_if_not_array< T >::type allocate_shared_noinit( A const & a )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T;
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- #if !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
- // Variadic templates, rvalue reference
- template< class T, class... Args > typename boost::detail::sp_if_not_array< T >::type make_shared( Args && ... args )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class... Args > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, Args && ... args )
- {
- #if !defined( BOOST_NO_CXX11_ALLOCATOR )
- typedef typename std::allocator_traits<A>::template rebind_alloc<T> A2;
- A2 a2( a );
- typedef boost::detail::sp_as_deleter< T, A2 > D;
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a2 );
- #else
- typedef boost::detail::sp_ms_deleter< T > D;
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_inplace_tag<D>(), a );
- #endif
- D * pd = static_cast< D* >( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- #if !defined( BOOST_NO_CXX11_ALLOCATOR )
- std::allocator_traits<A2>::construct( a2, static_cast< T* >( pv ), boost::detail::sp_forward<Args>( args )... );
- #else
- ::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
- #endif
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- #else // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
- // Common zero-argument versions
- template< class T > typename boost::detail::sp_if_not_array< T >::type make_shared()
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T();
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A > typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T();
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- // C++03 version
- template< class T, class A1 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4, class A5 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4, class A5 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4, class A5, class A6 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 ),
- boost::forward<A8>( a8 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 ),
- boost::forward<A8>( a8 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
- typename boost::detail::sp_if_not_array< T >::type make_shared( BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8, BOOST_FWD_REF(A9) a9 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 ),
- boost::forward<A8>( a8 ),
- boost::forward<A9>( a9 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 >
- typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, BOOST_FWD_REF(A1) a1, BOOST_FWD_REF(A2) a2, BOOST_FWD_REF(A3) a3, BOOST_FWD_REF(A4) a4, BOOST_FWD_REF(A5) a5, BOOST_FWD_REF(A6) a6, BOOST_FWD_REF(A7) a7, BOOST_FWD_REF(A8) a8, BOOST_FWD_REF(A9) a9 )
- {
- boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
- boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
- void * pv = pd->address();
- ::new( pv ) T(
- boost::forward<A1>( a1 ),
- boost::forward<A2>( a2 ),
- boost::forward<A3>( a3 ),
- boost::forward<A4>( a4 ),
- boost::forward<A5>( a5 ),
- boost::forward<A6>( a6 ),
- boost::forward<A7>( a7 ),
- boost::forward<A8>( a8 ),
- boost::forward<A9>( a9 )
- );
- pd->set_initialized();
- T * pt2 = static_cast< T* >( pv );
- boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
- return boost::shared_ptr< T >( pt, pt2 );
- }
- #endif // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
- #undef BOOST_SP_MSD
- } // namespace boost
- #endif // #ifndef BOOST_SMART_PTR_MAKE_SHARED_OBJECT_HPP_INCLUDED
|