smart pointers + “this” considered harmful?

后端 未结 8 1991
情书的邮戳
情书的邮戳 2020-12-14 12:10

In a C++ project that uses smart pointers, such as boost::shared_ptr, what is a good design philosophy regarding use of \"this\"?<

8条回答
  •  Happy的楠姐
    2020-12-14 12:36

    If you need to use this, just use it explicitly. Smart pointers wrap only pointers of the objects they own - either exclusivelly (unique_ptr) or in a shared manner (shared_ptr).

提交回复
热议问题