Enable move-only deleters in the nullptr_t constructors

This commit is contained in:
Peter Dimov
2021-05-11 02:15:27 +03:00
parent b52d7548b3
commit fec5fb97c8
2 changed files with 42 additions and 0 deletions

View File

@ -397,10 +397,20 @@ public:
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, static_cast< D&& >( d ) )
{
}
#else
template<class D> shared_ptr( boost::detail::sp_nullptr_t p, D d ): px( p ), pn( p, d )
{
}
#endif
#endif
// As above, but with allocator. A's copy constructor shall not throw.
@ -423,12 +433,22 @@ public:
#if !defined( BOOST_NO_CXX11_NULLPTR )
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, static_cast< D&& >( d ), a )
{
}
#else
template<class D, class A> shared_ptr( boost::detail::sp_nullptr_t p, D d, A a ): px( p ), pn( p, d, a )
{
}
#endif
#endif
// generated copy constructor, destructor are fine...
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )

View File

@ -125,6 +125,28 @@ int main()
BOOST_TEST( Y::instances == 0 );
}
#if !defined( BOOST_NO_CXX11_NULLPTR )
{
boost::shared_ptr<Y> p( nullptr, YD() );
YD del;
p = boost::shared_ptr<Y>( nullptr, std::move( del ) );
BOOST_TEST( del.moved_ );
}
{
boost::shared_ptr<Y> p( nullptr, YD(), std::allocator<Y>() );
YD del;
p = boost::shared_ptr<Y>( nullptr, std::move( del ), std::allocator<Y>() );
BOOST_TEST( del.moved_ );
}
#endif
return boost::report_errors();
}