Are there any downsides with using make_shared to create a shared_ptr

前端 未结 5 869
栀梦
栀梦 2020-12-12 20:33

Are there any downsides with using make_shared() instead of using shared_ptr(new T).

Boost documentation states

5条回答
  •  没有蜡笔的小新
    2020-12-12 21:12

    From http://www.codesynthesis.com/~boris/blog/2010/05/24/smart-pointers-in-boost-tr1-cxx-x0/

    The other drawback of the make_shared() implementation is the increase in the object code size. Due to the way this optimization is implemented, an additional virtual table as well as a set of virtual functions will be instantiated for each object type that you use with make_shared().

提交回复
热议问题