forked from boostorg/smart_ptr
Add constructor/assignment taking boost::movelib::unique_ptr
This commit is contained in:
1 parent
290fe82a43
commit
d875a68ceb
4 files changed
+311
-7
No files matched your search
@@ -55,6 +55,13 @@ template<class T> class weak_ptr;
|
||||
template<class T> class enable_shared_from_this;
|
||||
class enable_shared_from_raw;
|
||||
|
||||
namespace movelib
|
||||
{
|
||||
|
||||
template< class T, class D > class unique_ptr;
|
||||
|
||||
} // namespace movelib
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
@@ -495,6 +502,17 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
template< class Y, class D >
|
||||
shared_ptr( boost::movelib::unique_ptr< Y, D > r ): px( r.get() ), pn()
|
||||
{
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
|
||||
typename boost::movelib::unique_ptr< Y, D >::pointer tmp = r.get();
|
||||
pn = boost::detail::shared_count( r );
|
||||
|
||||
boost::detail::sp_deleter_construct( this, tmp );
|
||||
}
|
||||
|
||||
// assignment
|
||||
|
||||
shared_ptr & operator=( shared_ptr const & r ) BOOST_NOEXCEPT
|
||||
@@ -556,6 +574,27 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
template<class Y, class D>
|
||||
shared_ptr & operator=( boost::movelib::unique_ptr<Y, D> r )
|
||||
{
|
||||
// this_type( static_cast< unique_ptr<Y, D> && >( r ) ).swap( *this );
|
||||
|
||||
boost::detail::sp_assert_convertible< Y, T >();
|
||||
|
||||
typename boost::movelib::unique_ptr< Y, D >::pointer p = r.get();
|
||||
|
||||
shared_ptr tmp;
|
||||
|
||||
tmp.px = p;
|
||||
tmp.pn = boost::detail::shared_count( r );
|
||||
|
||||
boost::detail::sp_deleter_construct( &tmp, p );
|
||||
|
||||
tmp.swap( *this );
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Move support
|
||||
|
||||
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
|
||||
|
||||
Reference in new issue
Block a user