Top "Weak-ptr" questions

std::weak_ptr is a smart pointer that holds a non-owning ("weak") reference to an object that is managed by std::shared_ptr

When is std::weak_ptr useful?

I started studying smart pointers of C++11 and I don't see any useful use of std::weak_ptr. Can someone …

c++11 shared-ptr weak-ptr c++-faq
shared_ptr and weak_ptr differences

I am reading Scott Meyers "Effective C++" book. It was mentioned that there are tr1::shared_ptr and tr1::weak_…

c++ c++11 shared-ptr weak-ptr cyclic-reference
Is it correct to return null shared_ptr?

For example, there is a function that finds an object and returns shared_ptr if object is found, and must …

c++ shared-ptr smart-pointers weak-ptr
Why can't a weak_ptr be constructed from a unique_ptr?

If I understand correctly, a weak_ptr doesn't increment the reference count of the managed object, therefore it doesn't represent …

c++ shared-ptr smart-pointers unique-ptr weak-ptr
boost, shared ptr Vs weak ptr? Which to use when?

In my current project I am using boost::shared_ptr quite extensively. Recently my fellow team mates have also started …

c++ memory-management boost shared-ptr weak-ptr
How does weak_ptr work?

I understand how to use weak_ptr and shared_ptr. I understand how shared_ptr works, by counting the number …

c++ boost weak-references tr1 weak-ptr
Creating weak_ptr<> from raw pointer

I'd like to wrap raw pointer member to some smart pointer to prevent deleting inside a developing class. Owner of …

c++ pointers boost weak-ptr
why i can't cast nullptr to weak_ptr<>

class MyClass { public: MyClass(std::weak_ptr<MyClass> parent){} } i want to do this: auto newInstance = std::make_…

c++ casting null shared-ptr weak-ptr
Equality-compare std::weak_ptr

I want to compare two std::weak_ptr's or one std::weak_ptr and one std::shared_ptr for equality. …

c++ c++11 shared-ptr weak-ptr
How to check if weak_ptr is empty (non-assigned)?

Is there a way to distinguish between an assigned (possibly expired) weak_ptr and a non-assigned one. weak_ptr<…

c++ c++11 weak-ptr