weak-ptr

Is it wise to provide access to weak_ptr in a library interface?

I have written a library that exposes references to several related object types. All of these objects have their lifetimes managed by the library internally via boost::shared_ptr A user of the library would also be able to know, by nature of the library, the lifetimes of any of the exposed objects. So they could store pointers or kee...

boost, shared ptr Vs weak ptr? Which to use when?

Hello All, I am using boost shared pointer from considerable time in my project. Recently my fellow team mates have also started using weak pointers. I am not able to distinguish which to use when. Apart from this, what should I do if I want to convert weak ptr to shared ptr. Does putting a lock on weak ptr to create a shared ptr affec...

Avoiding indirect cyclic references when using shared_ptr and weak_ptr

I'm currently putting together an application that relies heavily on shared_ptr and everything looks good so far - I've done my homework and have a pretty good idea of some of the pitfalls of using shared_ptrs. One of the most recognised problems with shared_ptr is cyclic dependencies - these issues can be solved by storing weak_ptrs th...

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. Being a great fan of smart pointers I use shared_ptr's exclusively. However, in this case, the children in the tree will need access to it's parent (example -- beings on map need to be able to access map data -- ergo the dat...