Domanda

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:

  1. Am I correct? only new/delete?
  2. If so, Why?

Thanks!

È stato utile?

Soluzione

I believe you can use std::allocate_shared which allows you to use your own allocator.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top