When should I use raw pointers over smart pointers?

后端 未结 8 1443
礼貌的吻别
礼貌的吻别 2020-11-28 02:49

After reading this answer, it looks like it is a best practice to use smart pointers as much as possible, and to reduce the usage of \"normal\"/raw pointers to minimum.

8条回答
  •  清歌不尽
    2020-11-28 02:53

    Few cases, where you may want to use pointers:

    • Function pointers (obviously no smart pointer)
    • Defining your own smart pointer or container
    • Dealing with low level programming, where raw pointers are crucial
    • Decaying from raw arrays

提交回复
热议问题