A: Yes, make_shared
is your friend!
Recently on SO:
What happens when using make_shared
I'm interested if these two lines of code are the same:
shared_ptr<int> sp(new int(1)); // double allocation? shared_ptr<int> sp(make_shared<int>(1)); // just one allocation?If this is true could someone please explain why is it only one allocation in the second line?
Add a Comment
Comments are closed.