Move the unique_ptr deleter instead of copying it

This commit is contained in:
Peter Dimov
2021-05-11 01:20:02 +03:00
parent f3424e74e8
commit d41546ddce
4 changed files with 114 additions and 3 deletions
@@ -387,8 +387,8 @@ public:
{
typedef typename sp_convert_reference<D>::type D2;
D2 d2( r.get_deleter() );
pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), d2 );
D2 d2( static_cast<D&&>( r.get_deleter() ) );
pi_ = new sp_counted_impl_pd< typename std::unique_ptr<Y, D>::pointer, D2 >( r.get(), static_cast< D2&& >( d2 ) );
#ifdef BOOST_NO_EXCEPTIONS
@@ -145,7 +145,7 @@ template<class P, class D> class BOOST_SYMBOL_VISIBLE sp_counted_impl_pd: public
private:
P ptr; // copy constructor must not throw
D del; // copy constructor must not throw
D del; // copy/move constructor must not throw
sp_counted_impl_pd( sp_counted_impl_pd const & );
sp_counted_impl_pd & operator= ( sp_counted_impl_pd const & );
@@ -160,6 +160,14 @@ public:
{
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
sp_counted_impl_pd( P p, D && d ): ptr( p ), del( static_cast< D&& >( d ) )
{
}
#endif
sp_counted_impl_pd( P p ): ptr( p ), del()
{
}