Merge branch 'develop'

This commit is contained in:
Peter Dimov
2016-05-21 01:11:22 +03:00
2 changed files with 63 additions and 0 deletions

View File

@ -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)

View File

@ -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();
}