pros and cons of smart pointers

前端 未结 10 1962
长情又很酷
长情又很酷 2021-02-05 05:31

I came to know that smart pointer is used for resource management and supports RAII.

But what are the corner cases in which smart pointer doesn\'t seem smart and things

10条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 06:00

    Here are a few things

    • There's no definite entity which destroys the object. Often it is desired to know exactly when and how an object is being destroyed
    • Circular dependencies - If they exist you'll have a memory leak. That's usually where weak_ptr come to the rescue.

提交回复
热议问题