Have you checked the boost link for weak_ptr ?
shared_ptr<int> p(new int(5)); weak_ptr<int> q(p); // some time later if(shared_ptr<int> r = q.lock()) { // use *r }
The idea is that you block weak_ptr , thereby getting shared_ptr , which has statements.
First check if the resulting pointer points to something. A weak_ptr does not determine the life of the resource, but allows you to check whether the resource has already been destroyed.
Unclebens
source share