I understand:
shared_ptr<X> x = make_shared<X>();
is more efficient than:
shared_ptr<X> x(new X());
and I understand the advantages. However, I do not understand why the compiler could not have a rule like
"if I see
new()
in the same line as ashared_ptr
declaration, usemake_shared
"
So what is it which stops compilers from automatically using make_shared
and instead requiring us to specify it?