My goal is to have std::shared_ptr allocate ALL of its memory using a pool rather than the global memory resource (i.e., heap).
From what I can tell, might possible using constructor (6) from https://en.cppreference.com/w/cpp/memory/shared_ptr/shared_ptr
The Alloc template argument would need to be a reference/pointer type to my pool. However, I also know that this pool needs to allocate not just my type but some internal wrapper that std::shared_ptr uses for reference counting. std::make_shared allocates this magic structure and my type in the same block of memory. Thus, my pool would need to do the same thing.
However, my memory pool has the following type:
template <typename T, size_t SIZE>
class pool {
//...
template <typename ... ARGS>
T* create(ARGS&& ... args);
//...
};
To be used in std::shared_ptr, I think I would somehow need to get a hold of the internal type used by std::shared_ptr.
The same thing would apply with the deleter.
Is this possible?