Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add overloads for boost::make_shared() with more parameters.

  • Loading branch information...
commit d5c3593169237912940b96b7ba1137fc0470b447 1 parent 3ba5d96
@FooBarWidget FooBarWidget authored
Showing with 96 additions and 0 deletions.
  1. +96 −0 ext/boost/smart_ptr/make_shared.hpp
View
96 ext/boost/smart_ptr/make_shared.hpp
@@ -644,6 +644,66 @@ boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a
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, class A10 >
+boost::shared_ptr< T > make_shared( A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9, A10 && a10 )
+{
+ boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
+
+ boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt );
+
+ void * pv = pd->address();
+
+ ::new( pv ) T(
+ boost::detail::sp_forward<A1>( a1 ),
+ boost::detail::sp_forward<A2>( a2 ),
+ boost::detail::sp_forward<A3>( a3 ),
+ boost::detail::sp_forward<A4>( a4 ),
+ boost::detail::sp_forward<A5>( a5 ),
+ boost::detail::sp_forward<A6>( a6 ),
+ boost::detail::sp_forward<A7>( a7 ),
+ boost::detail::sp_forward<A8>( a8 ),
+ boost::detail::sp_forward<A9>( a9 ),
+ boost::detail::sp_forward<A9>( a10 )
+ );
+
+ 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, class A10 >
+boost::shared_ptr< T > allocate_shared( A const & a, A1 && a1, A2 && a2, A3 && a3, A4 && a4, A5 && a5, A6 && a6, A7 && a7, A8 && a8, A9 && a9, A10 && a10 )
+{
+ boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
+
+ boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt );
+
+ void * pv = pd->address();
+
+ ::new( pv ) T(
+ boost::detail::sp_forward<A1>( a1 ),
+ boost::detail::sp_forward<A2>( a2 ),
+ boost::detail::sp_forward<A3>( a3 ),
+ boost::detail::sp_forward<A4>( a4 ),
+ boost::detail::sp_forward<A5>( a5 ),
+ boost::detail::sp_forward<A6>( a6 ),
+ boost::detail::sp_forward<A7>( a7 ),
+ boost::detail::sp_forward<A8>( a8 ),
+ boost::detail::sp_forward<A9>( a9 ),
+ boost::detail::sp_forward<A9>( a10 )
+ );
+
+ 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
// C++03 version
@@ -972,6 +1032,42 @@ boost::shared_ptr< T > allocate_shared( A const & a, A1 const & a1, A2 const & a
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, class A10 >
+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, A10 const &a10 )
+{
+ boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
+
+ boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt );
+
+ void * pv = pd->address();
+
+ ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 );
+ 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, class A10 >
+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, A10 const & a10 )
+{
+ boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ), a );
+
+ boost::detail::sp_ms_deleter< T > * pd = boost::get_deleter< boost::detail::sp_ms_deleter< T > >( pt );
+
+ void * pv = pd->address();
+
+ ::new( pv ) T( a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 );
+ 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
#undef BOOST_SP_MSD

0 comments on commit d5c3593

Please sign in to comment.
Something went wrong with that request. Please try again.