I want to preallocate memory both for control block and value_type
for shared_ptr
in one heap request (like std::make_shared
), but do not construct immediately any object in it. And when I actually need to construct object use placement new
. Is it possible? Neither std::make_shared
or std::allocate_shared
seem to solve my problem.
I would propose to create postponed initialization wrapper class that contains enough memory within itself for object you want to initialize later. This wrapper could even have special method for invoking placement new and delete initialized object in destructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With