mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-08-02 06:04:27 +02:00
Reintroduced weak_ptr converting constructor; map<weak_ptr<>, ...> is important.
[SVN r16400]
This commit is contained in:
@@ -60,10 +60,12 @@ public:
|
|||||||
// It is not possible to avoid spurious access violations since
|
// It is not possible to avoid spurious access violations since
|
||||||
// in multithreaded programs r.px may be invalidated at any point.
|
// in multithreaded programs r.px may be invalidated at any point.
|
||||||
//
|
//
|
||||||
// A weak_ptr<T> can safely be obtained from a weak_ptr<U> by using
|
|
||||||
//
|
template<class Y>
|
||||||
// weak_ptr<T> wpt = make_shared(wpu);
|
weak_ptr(weak_ptr<Y> const & r): pn(r.pn) // never throws
|
||||||
//
|
{
|
||||||
|
px = boost::make_shared(r).get();
|
||||||
|
}
|
||||||
|
|
||||||
template<class Y>
|
template<class Y>
|
||||||
weak_ptr(shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
|
weak_ptr(shared_ptr<Y> const & r): px(r.px), pn(r.pn) // never throws
|
||||||
@@ -72,6 +74,14 @@ public:
|
|||||||
|
|
||||||
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
|
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
|
||||||
|
|
||||||
|
template<class Y>
|
||||||
|
weak_ptr & operator=(weak_ptr<Y> const & r) // never throws
|
||||||
|
{
|
||||||
|
px = boost::make_shared(r).get();
|
||||||
|
pn = r.pn;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<class Y>
|
template<class Y>
|
||||||
weak_ptr & operator=(shared_ptr<Y> const & r) // never throws
|
weak_ptr & operator=(shared_ptr<Y> const & r) // never throws
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user