yaml-cpp
yaml-cpp copied to clipboard
Replace std::shared_ptr<T>(T*) usage in order to prevent additional memory allocation for shared_ptr control block
Sure. When the first owner of shared_ptr is created with a constructor from a pointer, it allocates memory for a control block used to reference counting. make_shared method allocates memory for that control block and the object that pointer is stored, with the same allocation - thus 1 extra allocation is eliminated. More precise description is available in the "notes" section here https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared.html