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

About thread-safety of weak_ptr

std::shared_ptr<int> g_s = std::make_shared<int>(1); void f1() { std::shared_ptr<…

c++ multithreading c++11 weak-ptr
What is diffrence between lock() and expired()? weak_ptr C++

Recently I started at C++11. I studied about weak_ptr. There exist two ways of getting raw pointer. lock() function …

c++ c++11 shared-ptr smart-pointers weak-ptr
std::unique_ptr vs std::shared_ptr vs std::weak_ptr vs std::auto_ptr vs raw pointers

What are the equivalent uses of each smart pointer in comparison to similar (but not limited to) some advanced techniques …

c++ shared-ptr unique-ptr auto-ptr weak-ptr
shared_ptr and cyclic references

I was trying with the cyclic references for boost::shared_ptr, and devised following sample: class A{ // Trivial class public: …

c++ shared-ptr weak-ptr cyclic-reference
What's the performance penalty of weak_ptr?

I'm currently designing a object structure for a game, and the most natural organization in my case became a tree. …

c++ performance boost weak-ptr
Binding to a weak_ptr

Is there a way to std::bind to a std::weak_ptr? I'd like to store a "weak function" callback …

c++ callback bind weak-ptr std-function
Is there a weak_ptr equivalent to shared_from_this?

I have a class which I know will always be owned by a std::shared_ptr. However passing shared_ptr …

c++ pointers c++14 shared-ptr weak-ptr
Do I have to use weak_ptr.lock() just to test if it points to a valid object?

It seems kind of inefficient to have to create a temporary shared_ptr just to see if the weak_ptr …

c++ shared-ptr weak-ptr
What's the difference between raw pointer and weak_ptr?

As in title. This question probably already has an answer but I failed to find one.

c++ weak-ptr raw-pointer
How to make a c++11 std::unordered_set of std::weak_ptr

I have a set like this: set<weak_ptr<Node>, owner_less<weak_ptr<Node&…

c++ c++11 std unordered-set weak-ptr