|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81861 - trunk/boost/smart_ptr
From: pdimov_at_[hidden]
Date: 2012-12-11 13:32:25
Author: pdimov
Date: 2012-12-11 13:32:24 EST (Tue, 11 Dec 2012)
New Revision: 81861
URL: http://svn.boost.org/trac/boost/changeset/81861
Log:
Add allocate_shared_noinit.
Text files modified:
trunk/boost/smart_ptr/make_shared_object.hpp | 17 +++++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)
Modified: trunk/boost/smart_ptr/make_shared_object.hpp
==============================================================================
--- trunk/boost/smart_ptr/make_shared_object.hpp (original)
+++ trunk/boost/smart_ptr/make_shared_object.hpp 2012-12-11 13:32:24 EST (Tue, 11 Dec 2012)
@@ -182,6 +182,23 @@
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_HAS_VARIADIC_TMPL ) && defined( BOOST_HAS_RVALUE_REFS )
// Variadic templates, rvalue reference
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk