From de38a735ea7793f9c7e747e49e3ce3900b92ab46 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Sun, 24 Jul 2016 14:38:21 +0200 Subject: [PATCH] boost::make_shared: use Constructor Forwarding on C++03 Use Boost.Move's move emulation and documented Constructor Forwarding technique to provide (partial) constructor forwarding on compilers that don't support r-value references. This allows constructing types taking movable-but-not-copyable types as constructor arguments. Additionally it's generally more efficient for movable-and-copyable types, but that's just a nice-to-have. --- include/boost/smart_ptr/make_shared_object.hpp | 570 ++++++------------------- 1 file changed, 120 insertions(+), 450 deletions(-) diff --git a/include/boost/smart_ptr/make_shared_object.hpp b/include/boost/smart_ptr/make_shared_object.hpp index 62372fa..3bc78ee 100644 --- a/include/boost/smart_ptr/make_shared_object.hpp +++ b/include/boost/smart_ptr/make_shared_object.hpp @@ -13,6 +13,8 @@ // for documentation. #include +#include +#include #include #include #include @@ -338,12 +340,10 @@ template< class T, class A > typename boost::detail::sp_if_not_array< T >::type return boost::shared_ptr< T >( pt, pt2 ); } -#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - -// For example MSVC 10.0 +// C++03 version template< class T, class A1 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && 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 ) ); @@ -352,7 +352,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1 ) void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ) + boost::forward( a1 ) ); pd->set_initialized(); @@ -364,7 +364,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1 ) } template< class T, class A, class A1 > -typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && 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 ); @@ -372,8 +372,8 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ) + ::new( pv ) T( + boost::forward( a1 ) ); pd->set_initialized(); @@ -385,7 +385,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } template< class T, class A1, class A2 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && 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 ) ); @@ -394,8 +394,8 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ) + boost::forward( a1 ), + boost::forward( a2 ) ); pd->set_initialized(); @@ -407,7 +407,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } template< class T, class A, class A1, class A2 > -typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, A1 && a1, A2 && 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 ); @@ -415,9 +415,9 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ) ); pd->set_initialized(); @@ -429,7 +429,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } template< class T, class A1, class A2, class A3 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && 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 ) ); @@ -438,9 +438,9 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ) ); pd->set_initialized(); @@ -452,7 +452,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && 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 ); @@ -460,10 +460,10 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ) ); pd->set_initialized(); @@ -475,7 +475,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } template< class T, class A1, class A2, class A3, class A4 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && 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 ) ); @@ -484,10 +484,10 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ) ); pd->set_initialized(); @@ -499,7 +499,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && 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 ); @@ -507,11 +507,11 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ) ); pd->set_initialized(); @@ -523,7 +523,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } template< class T, class A1, class A2, class A3, class A4, class A5 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && 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 ) ); @@ -532,11 +532,11 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ) ); pd->set_initialized(); @@ -548,7 +548,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && 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 ); @@ -556,12 +556,12 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ) ); pd->set_initialized(); @@ -573,7 +573,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } 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( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && 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 ) ); @@ -582,12 +582,12 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ) ); pd->set_initialized(); @@ -599,7 +599,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && 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 ); @@ -607,13 +607,13 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ) ); pd->set_initialized(); @@ -625,7 +625,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } 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( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && 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 ) ); @@ -634,13 +634,13 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ) ); pd->set_initialized(); @@ -652,7 +652,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && 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 ); @@ -660,14 +660,14 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ) ); pd->set_initialized(); @@ -679,7 +679,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } 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( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && 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 ) ); @@ -688,14 +688,14 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ), - boost::detail::sp_forward( a8 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ), + boost::forward( a8 ) ); pd->set_initialized(); @@ -707,7 +707,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && 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 ); @@ -715,15 +715,15 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ), - boost::detail::sp_forward( a8 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ), + boost::forward( a8 ) ); pd->set_initialized(); @@ -735,7 +735,7 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, } 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( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && 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 ) ); @@ -744,15 +744,15 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && void * pv = pd->address(); ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ), - boost::detail::sp_forward( a8 ), - boost::detail::sp_forward( a9 ) + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ), + boost::forward( a8 ), + boost::forward( a9 ) ); pd->set_initialized(); @@ -764,7 +764,7 @@ typename boost::detail::sp_if_not_array< T >::type make_shared( A1 && a1, A2 && } 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, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && 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 ); @@ -772,16 +772,16 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, void * pv = pd->address(); - ::new( pv ) T( - boost::detail::sp_forward( a1 ), - boost::detail::sp_forward( a2 ), - boost::detail::sp_forward( a3 ), - boost::detail::sp_forward( a4 ), - boost::detail::sp_forward( a5 ), - boost::detail::sp_forward( a6 ), - boost::detail::sp_forward( a7 ), - boost::detail::sp_forward( a8 ), - boost::detail::sp_forward( a9 ) + ::new( pv ) T( + boost::forward( a1 ), + boost::forward( a2 ), + boost::forward( a3 ), + boost::forward( a4 ), + boost::forward( a5 ), + boost::forward( a6 ), + boost::forward( a7 ), + boost::forward( a8 ), + boost::forward( a9 ) ); pd->set_initialized(); @@ -792,336 +792,6 @@ typename boost::detail::sp_if_not_array< T >::type allocate_shared( A const & a, return boost::shared_ptr< T >( pt, pt2 ); } -#else // !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) - -// C++03 version - -template< class T, class A1 > -typename boost::detail::sp_if_not_array< T >::type make_shared( A1 const & a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( 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, A1 const & a1 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( 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( A1 const & a1, A2 const & a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, 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, A1 const & a1, A2 const & a2 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, 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( A1 const & a1, A2 const & a2, A3 const & a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, 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, A1 const & a1, A2 const & a2, A3 const & a3 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, 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( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, 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, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, 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( A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, 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, A1 const & a1, A2 const & a2, A3 const & a3, A4 const & a4, A5 const & a5 ) -{ - boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, 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( 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 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, 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, 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 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, 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( 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 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, 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, 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 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, 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( 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 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, 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, 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 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, 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( 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 ), BOOST_SP_MSD( T ) ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, 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, 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 ), BOOST_SP_MSD( T ), a ); - - boost::detail::sp_ms_deleter< T > * pd = static_cast *>( pt._internal_get_untyped_deleter() ); - - void * pv = pd->address(); - - ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, 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_RVALUE_REFERENCES ) - #endif // !defined( BOOST_NO_CXX11_VARIADIC_TEMPLATES ) && !defined( BOOST_NO_CXX11_RVALUE_REFERENCES ) #undef BOOST_SP_MSD -- 2.8.4