Optimize make_local_shared to use a single allocation

This commit is contained in:
Peter Dimov
2017-06-20 04:27:45 +03:00
parent 1f86907a3d
commit 2b5869882a
9 changed files with 316 additions and 62 deletions

View File

@@ -61,6 +61,28 @@ int main()
BOOST_TEST( X::instances == 0 );
{
boost::shared_ptr< X > px = boost::make_shared_noinit< X >();
BOOST_TEST( X::instances == 1 );
try
{
boost::shared_ptr< X > qx = px->shared_from_this();
BOOST_TEST( px == qx );
BOOST_TEST( !( px < qx ) && !( qx < px ) );
px.reset();
BOOST_TEST( X::instances == 1 );
}
catch( boost::bad_weak_ptr const& )
{
BOOST_ERROR( "px->shared_from_this() failed" );
}
}
BOOST_TEST( X::instances == 0 );
{
boost::shared_ptr< X > px = boost::make_shared< X >( 1 );
BOOST_TEST( X::instances == 1 );