make_shared vs shared_ptr ctor:

See debates here:

c++11 – Difference in make_shared and normal shared_ptr in C++ – Stack Overflow


  • make_shared 只涉及一次堆内存分配,shared_ptr ctor 涉及两次(new the Control Block. new an Object to be managed.);
make_shared 的一个可能实现(g++ 9.2.0)
  • 详见图(不支持 non-public 构造函数),~~虽然我觉得这个纯属是抬杠~~;
  • 从 Efficiency 的角度来说,make_shared 不一定更优,从异常安全(Exception Safety)的角度来说,make_shared 会更好.

What is Linkage?

c++ – What is external linkage and internal linkage? – Stack Overflow


A little learning is a dangerous thing.


您的电子邮箱地址不会被公开。 必填项已用*标注