I'm reading "Beyond the C++ Standard Library: An Introduction to Boost" and it says you'd use a weak_ptr to:
- Break cyclic dependencies
- Use a shared resource without sharing ownership
- Avoid dangling pointers
I sort of understand about breaking cyclic dependencies, although I've never written anything that could ever get in that state.
But why would you want to use a shared resource without sharing ownership? If you plan to use it, why would you use a weak_ptr which could become NULL at any moment?



LinkBack URL
About LinkBacks




CornedBee
I guess weak_ptr's would make sense in this example.