mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-30 04:47:12 +02:00
Enable move-only deleters in the nullptr_t constructors
This commit is contained in:
@ -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 )
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user