Add aliasing constructors to weak_ptr. Closes #67.

This commit is contained in:
Peter Dimov
2019-04-21 22:43:04 +03:00
parent 7bfa6a1f3d
commit 513cd15378

View File

@@ -137,6 +137,23 @@ public:
boost::detail::sp_assert_convertible< Y, T >(); boost::detail::sp_assert_convertible< Y, T >();
} }
// aliasing
template<class Y> weak_ptr(shared_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
{
}
template<class Y> weak_ptr(weak_ptr<Y> const & r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( r.pn )
{
}
#if !defined( BOOST_NO_CXX11_RVALUE_REFERENCES )
template<class Y> weak_ptr(weak_ptr<Y> && r, element_type * p) BOOST_SP_NOEXCEPT: px( p ), pn( std::move( r.pn ) )
{
}
#endif
#if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300) #if !defined(BOOST_MSVC) || (BOOST_MSVC >= 1300)
template<class Y> template<class Y>
@@ -194,6 +211,11 @@ public:
return pn.empty(); return pn.empty();
} }
bool empty() const BOOST_SP_NOEXCEPT // extension, not in std::weak_ptr
{
return pn.empty();
}
void reset() BOOST_SP_NOEXCEPT void reset() BOOST_SP_NOEXCEPT
{ {
this_type().swap(*this); this_type().swap(*this);