mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-30 04:47:12 +02:00
@ -139,7 +139,7 @@ template< class T, class A > boost::shared_ptr< T > allocate_shared( A const & a
|
|||||||
|
|
||||||
// Variadic templates, rvalue reference
|
// Variadic templates, rvalue reference
|
||||||
|
|
||||||
template< class T, class... Args > boost::shared_ptr< T > make_shared( Args && ... args )
|
template< class T, class Arg1, class... Args > boost::shared_ptr< T > make_shared( Arg1 && arg1, Args && ... args )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_ms_deleter< T >() );
|
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_ms_deleter< T >() );
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ template< class T, class... Args > boost::shared_ptr< T > make_shared( Args && .
|
|||||||
|
|
||||||
void * pv = pd->address();
|
void * pv = pd->address();
|
||||||
|
|
||||||
::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
|
::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ), boost::detail::sp_forward<Args>( args )... );
|
||||||
pd->set_initialized();
|
pd->set_initialized();
|
||||||
|
|
||||||
T * pt2 = static_cast< T* >( pv );
|
T * pt2 = static_cast< T* >( pv );
|
||||||
@ -156,7 +156,7 @@ template< class T, class... Args > boost::shared_ptr< T > make_shared( Args && .
|
|||||||
return boost::shared_ptr< T >( pt, pt2 );
|
return boost::shared_ptr< T >( pt, pt2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class T, class A, class... Args > boost::shared_ptr< T > allocate_shared( A const & a, Args && ... args )
|
template< class T, class A, class Arg1, class... Args > boost::shared_ptr< T > allocate_shared( A const & a, Arg1 && arg1, Args && ... args )
|
||||||
{
|
{
|
||||||
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_ms_deleter< T >(), a );
|
boost::shared_ptr< T > pt( static_cast< T* >( 0 ), boost::detail::sp_ms_deleter< T >(), a );
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ template< class T, class A, class... Args > boost::shared_ptr< T > allocate_shar
|
|||||||
|
|
||||||
void * pv = pd->address();
|
void * pv = pd->address();
|
||||||
|
|
||||||
::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
|
::new( pv ) T( boost::detail::sp_forward<Arg1>( arg1 ), boost::detail::sp_forward<Args>( args )... );
|
||||||
pd->set_initialized();
|
pd->set_initialized();
|
||||||
|
|
||||||
T * pt2 = static_cast< T* >( pv );
|
T * pt2 = static_cast< T* >( pv );
|
||||||
|
@ -63,5 +63,6 @@ import testing ;
|
|||||||
[ compile-fail auto_ptr_lv_fail.cpp ]
|
[ compile-fail auto_ptr_lv_fail.cpp ]
|
||||||
[ run atomic_count_test2.cpp ]
|
[ run atomic_count_test2.cpp ]
|
||||||
[ run sp_typeinfo_test.cpp ]
|
[ run sp_typeinfo_test.cpp ]
|
||||||
|
[ compile make_shared_fp_test.cpp ]
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
19
test/make_shared_fp_test.cpp
Normal file
19
test/make_shared_fp_test.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//
|
||||||
|
// make_shared_fp_test.cpp
|
||||||
|
//
|
||||||
|
// Copyright 2010 Georg Fritzsche
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/make_shared.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
typedef boost::shared_ptr<int>(*FP)();
|
||||||
|
FP fp = boost::make_shared<int>;
|
||||||
|
}
|
Reference in New Issue
Block a user