《Effective Modern C++》item 20:std::weak_ptr

                                                  采取行动乃消除焦虑的最好办法之一。


Use std::weak_ptr for std::shared_ptr like pointers that can dangle.
 


 关于shared_ptr:

关于shared_ptr和weak_ptr的实现:


-------weak_ptr是shared_ptr的补充,其指向一个资源,但是不会影响该资源的引用计数:

《Effective Modern C++》item 20:std::weak_ptr

-------weak_ptr一般通过shared_ptr进行初始化,即指向已经被shared_ptr托管的对象,当shared_ptr托管的这个对象

被销毁侯,weak_ptr会编程野指针, 但是,weak_ptr没有提供解引用的操作,这样似乎安全了许多。通常,人们对

weak_ptr的使用是调用其expired函数以检查其所指向的资源是否已经被销毁了:

《Effective Modern C++》item 20:std::weak_ptr

 《Effective Modern C++》item 20:std::weak_ptr