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

后端 未结 4 1662
星月不相逢
星月不相逢 2020-12-23 00:03

In my current project I am using boost::shared_ptr quite extensively.

Recently my fellow team mates have also started using weak_ptr. I don

4条回答
  •  半阙折子戏
    2020-12-23 00:21

    You should probably not be trying to use weak pointers at all unless you are trying to implement a garbage collector, which is not a hot idea in C++ because it's too hard to keep track of everything that could go wrong closely enough.

提交回复
热议问题