mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-01 21:54:28 +02:00
Add aliasing constructors to weak_ptr. Closes #67.
This commit is contained in:
@@ -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);
|
||||||
|
Reference in New Issue
Block a user