Index: make_shared.hpp =================================================================== --- make_shared.hpp (revision 823) +++ make_shared.hpp (working copy) @@ -88,38 +88,332 @@ } // namespace detail -// Zero-argument versions -// -// Used even when variadic templates are available because of the new T() vs new T issue - -template< class T > boost::shared_ptr< T > make_shared() +namespace detail { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); +class make_shared_access +{ +public: - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + template< class T > + static boost::shared_ptr< T > make_shared() + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - void * pv = pd->address(); + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - new( pv ) T(); - pd->set_initialized(); + void * pv = pd->address(); - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); -} + new( pv ) T(); + pd->set_initialized(); -template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + template< class T, class A > + static boost::shared_ptr< T > allocate_shared( A const & a ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - void * pv = pd->address(); + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - new( pv ) T(); - pd->set_initialized(); + void * pv = pd->address(); - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + new( pv ) T(); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + +#if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS ) + /// @todo implement var args version +#else + template< class T, class A1 > + static boost::shared_ptr< T > make_shared( A1 const & a1 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1 > + static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2 > + static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2 > + static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3 > + static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3 > + static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4 > + static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4 > + static boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4, class A5 > + static boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4, class A5 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } + + template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > + 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 ) + { + boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + + detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); + + void * pv = pd->address(); + + new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); + pd->set_initialized(); + + return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + } +#endif +}; +} // namespace detail + +// Zero-argument versions +// +// Used even when variadic templates are available because of the new T() vs new T issue + +template< class T > boost::shared_ptr< T > make_shared() +{ + return detail::make_shared_access::make_shared(); } +template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a ) +{ + return detail::make_shared_access::allocate_shared(); +} + #if defined( BOOST_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS ) // Variadic templates, rvalue reference @@ -159,273 +453,113 @@ template< class T, class A1 > boost::shared_ptr< T > make_shared( A1 const & a1 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1); } template< class T, class A, class A1 > boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1); } template< class T, class A1, class A2 > boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2); } template< class T, class A, class A1, class A2 > boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2); } template< class T, class A1, class A2, class A3 > boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3); } template< class T, class A, class A1, class A2, class A3 > boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3); } template< class T, class A1, class A2, class A3, class A4 > boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4); } template< class T, class A, class A1, class A2, class A3, class A4 > boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4); } template< class T, class A1, class A2, class A3, class A4, class A5 > boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4,a5); } template< class T, class A, class A1, class A2, class A3, class A4, class A5 > boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4,a5); } template< class T, class A1, class A2, class A3, class A4, class A5, class A6 > boost::shared_ptr< T > make_shared( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5, A6 const & a6 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4,a5,a6); } template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4,a5,a6); } template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4,a5,a6,a7); } template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4,a5,a6,a7); } template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4,a5,a6,a7,a8); } template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4,a5,a6,a7,a8); } template< class T, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >() ); - - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); - - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); + return detail::make_shared_access::make_shared(a1,a2,a3,a4,a5,a6,a7,a8,a9); } template< class T, class A, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9 > 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 ) { - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), detail::sp_ms_deleter< T >(), a ); + return detail::make_shared_access::allocate_shared(a,a1,a2,a3,a4,a5,a6,a7,a8,a9); +} - detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt ); +using detail::make_shared_access; - void * pv = pd->address(); - - new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9 ); - pd->set_initialized(); - - return boost::shared_ptr< T >( pt, static_cast< T* >( pv ) ); -} - #endif } // namespace boost