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
+19
View File
@@ -61,6 +61,12 @@ int main()
BOOST_TEST( *pi == 0 );
}
{
boost::shared_ptr< int > pi = boost::make_shared_noinit< int >();
BOOST_TEST( pi.get() != 0 );
}
{
boost::shared_ptr< int > pi = boost::make_shared< int >( 5 );
@@ -83,6 +89,19 @@ int main()
BOOST_TEST( X::instances == 0 );
}
{
boost::shared_ptr< X > pi = boost::make_shared_noinit< X >();
boost::weak_ptr<X> wp( pi );
BOOST_TEST( X::instances == 1 );
BOOST_TEST( pi.get() != 0 );
BOOST_TEST( pi->v == 0 );
pi.reset();
BOOST_TEST( X::instances == 0 );
}
{
boost::shared_ptr< X > pi = boost::make_shared< X >( 1 );
boost::weak_ptr<X> wp( pi );