std::shared_ptr<Object> p1 = std::make_shared<Object>("foo");
std::shared_ptr<Object> p2(new Object("foo"));
Many google and stackoverflow posts are there on this, but I am not able to understand why make_shared
is more efficient than directly using shared_ptr
.
Can someone explain me step by step sequence of objects created and operations done by both so that I will be able to understand how make_shared
is efficient. I have given one example above for reference.
Aucun commentaire:
Enregistrer un commentaire