From af6fe18c9d2f383e10f584df899963aeb89ca1fa Mon Sep 17 00:00:00 2001
From: Peter Dimov The weak_ptr class template stores a pointer to an object that's already
- managed by a shared_ptr. When the object last shared_ptr to the
- object goes away and the object is deleted, all weak_ptr objects have
- their stored pointers set to 0.weak_ptr
class template
Every weak_ptr meets the CopyConstructible and Assignable requirements of the C++ Standard Library, and so can be used in standard library containers. Comparison operators are supplied so that weak_ptr works with the @@ -30,7 +30,7 @@ weak_ptr<int> q(p); if(int * r = q.get()) { - // use *r + // use *r }
Imagine that after the if, but immediately before r @@ -46,7 +46,7 @@ weak_ptr<int> q(p); if(shared_ptr<int> r = make_shared(q)) { - // use *r + // use *r }
Now r holds a reference to the object that was pointed by q. @@ -101,7 +101,7 @@ if(shared_ptr<int> r = make_shared(q))
Provides the type of the template parameter T.
explicit weak_ptr();+
weak_ptr();
Effects: Constructs a weak_ptr.
Postconditions: use count is 0; the stored