forked from boostorg/smart_ptr
Merge branch 'develop'
This commit is contained in:
@ -122,6 +122,30 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class U> friend class intrusive_ptr;
|
||||
|
||||
template<class U>
|
||||
#if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
|
||||
|
||||
intrusive_ptr(intrusive_ptr<U> && rhs, typename boost::detail::sp_enable_if_convertible<U,T>::type = boost::detail::sp_empty())
|
||||
|
||||
#else
|
||||
|
||||
intrusive_ptr(intrusive_ptr<U> && rhs)
|
||||
|
||||
#endif
|
||||
: px( rhs.px )
|
||||
{
|
||||
rhs.px = 0;
|
||||
}
|
||||
|
||||
template<class U>
|
||||
intrusive_ptr & operator=(intrusive_ptr<U> && rhs) BOOST_NOEXCEPT
|
||||
{
|
||||
this_type( static_cast< intrusive_ptr<U> && >( rhs ) ).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
intrusive_ptr & operator=(intrusive_ptr const & rhs)
|
||||
|
@ -143,6 +143,18 @@ int main()
|
||||
BOOST_TEST( N::base::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::intrusive_ptr<Y> p( new Y );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
|
||||
boost::intrusive_ptr<X> p2( std::move( p ) );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( N::base::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::intrusive_ptr<X> p( new X );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
@ -170,6 +182,33 @@ int main()
|
||||
BOOST_TEST( N::base::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::intrusive_ptr<Y> p( new Y );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
|
||||
boost::intrusive_ptr<X> p2;
|
||||
p2 = std::move( p );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( N::base::instances == 0 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::intrusive_ptr<Y> p( new Y );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
|
||||
boost::intrusive_ptr<X> p2( new X );
|
||||
BOOST_TEST( N::base::instances == 2 );
|
||||
p2 = std::move( p );
|
||||
BOOST_TEST( N::base::instances == 1 );
|
||||
BOOST_TEST( p.get() == 0 );
|
||||
|
||||
p2.reset();
|
||||
BOOST_TEST( N::base::instances == 0 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user