This linked question asked if the make_shared<>
function and the shared_ptr<>
constructor differ.
What happens when using make_shared
Part of the answer was that make_shared<>
will usually allocate memory for both the pointed to object and smart pointer control block in a single allocation. The shared_ptr<>
constructors use two allocations.
cppreference states that the constructors "must" do so but no reason is given.
Why is this? Is it for some reason impossible? Or is it forbidden by the standard for some other reason?