Difference in make_shared and normal shared_ptr in C++
The difference is that std::make_shared performs one heap-allocation, whereas calling the std::shared_ptr constructor performs two. Where do the heap-allocations happen? std::shared_ptr manages two entities: the control block (stores meta data such as ref-counts, type-erased deleter, etc) the object being managed std::make_shared performs a single heap-allocation accounting for the space necessary for both the control block and the data. In the other … Read more