The weak_ptr<> is class template that can be used in place of shared_ptr<> to break cycles in data structures.
using std::tr1::weak_ptr;
Member function lock() and constructors:
shared_ptr<int> sp2(wp2); // throw if wp is expired shared_ptr<int> sp2 = wp2.lock(); // return a default-constructed sp if wp is expired
Member function expired:return true if the weak_ptr is expired:
bool weak_ptr<Ty>::expired() const; if (wp.expired())
Member function use_count:return the number of shared_ptr that own the resource:
long weak_ptr<Ty>::use_count() const;
Member function operator=:
weak_ptr::operator=(const weak_ptr &wp); weak_ptr::operator=(const weak_ptr<O> &wp); weak_ptr::operator=(shared_ptr<O> &sp);
Member function operator<:
The function implements a strict weak ordering: !(lhs < rhs) && !(rhs <lhs) is true only if lhs and rhs control the same resource.
template<class T1, class T2> bool operator< (const weak_ptr<T1> & lhs, const weak_ptr<T2> &rhs);
Member function reset and swap: void weak_ptr<Ty>::reset() const; void weak_ptr<Ty>::swap(weak_ptr<Ty> &rh);
|