I believe you can use std::allocate_shared
which allows you to use your own allocator.
make_shared how to use non default memory management
-
02-04-2022 - |
Question
I have a question about the standard..
So let's say I have pools that manage my memory allocation..
I wanted to use shared_ptr and checked out the API..
As expected, I see that for shared_ptr I control the allocation of the pointer and I can give it a dealloction function, Perfect!!
Now I've watched STL's lectures and I find that maked_shared is more memory efficient (since it can allocate the control block and ptr at the same place) Obviously I went straight away to the maked_shared api, only to find out that make_shared is forcing me to use new/delete only.. So Questions would be:
- Am I correct? only new/delete?
- If so, Why?
Thanks!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow