questions regarding shared_from_this

前端 未结 5 1844
野趣味
野趣味 2020-12-28 14:55

I have a function which takes a shared_ptr. In some member function memfun of MyClass, I need to pass this

5条回答
  •  暖寄归人
    2020-12-28 15:37

    In addition with David Rodríguez - dribeas, shared pointer isn't recommended by google

    It maintains reference count internally, so making it work correctly, InterlockedIncrement and InterlockedDecrement are used, these two functions are really slower than normal ++ and --.

    You should check this object ownership truly need be shared with others, per my experience, shared pointer could be avoided in most cases.

提交回复
热议问题