pros and cons of smart pointers

前端 未结 10 1933
长情又很酷
长情又很酷 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:25

    Beside technical limitations (already mentioned : circular dependencies), i'd say that the most important thing about smart pointers is to remember that it's still a workaround to get heap-allocated-objects deleted. Stack allocation is the best option for most cases - along with the use of references - to manage the lifetime of objects.

提交回复
热议问题