c ++ 11 – C ++ memory pool shared_ptr

I've collected this small class of memory pools to avoid the costs associated with heap allocation and deallocation of frequently created and destroyed objects. He creates C ++ shared_ptrs with custom deletes that return objects pointed to the memory pool where they can be recycled. At the moment, it uses the moodycamel queue to handle the pool, but it could be rewritten to use a simple vector or stack.

I would appreciate your comments on the design / implementation

#ifndef SHAREDPTRMEMORYPOOL_H
#define SHAREDPTRMEMORYPOOL_H

#understand 
#understand <3rdParty/spsc_queue/readerwriterqueue.h>

// The objects to be managed must have a default constructor
// and a rebuild function (...) that is used to initialize
// their state (as a constructor)
//
// Use as:
// auto obj = make_shared_ptr_from_pool (my_memory_pool, my_reconstruct_args, ...);


model
SharedPtrMemoryPool class {
public:
Explicit SharedPtrMemoryPool (unsigned int num_to_prealloc);
~ SharedPtrMemoryPool ();

std :: shared_ptr get_shared_ptr ();
void release_shared_ptr (TPointedToClass * to_release);

private:
moodycamel :: ReaderWriterQueue _pointer_queue;
};


model
SharedPtrMemoryPool:: SharedPtrMemoryPool (unsigned int num_to_prealloc) {
for (unsigned int i = 0; i <num_to_prealloc; ++ i) {
auto prealloc_item = new TPointedToClass ();
_pointer_queue.enqueue (prealloc_item);
}
}

model
SharedPtrMemoryPool:: ~ SharedPtrMemoryPool () {
TPointedToClass * raw_ptr;
while (_pointer_queue.try_dequeue (raw_ptr)) {
delete raw_ptr;
}
}

model
std :: shared_ptr SharedPtrMemoryPool:: get_shared_ptr () {
TPointedToClass * raw_retval;
bool recycle_success = _pointer_queue.try_dequeue (raw_retval);
if (! recycle_success) {
raw_retval = new TPointedToClass ();
}

returns std :: shared_ptr(Raw_retval, [this](TPointedToClass * to_release) {
this-> release_shared_ptr (to_release);
});
}

model
canceled SharedPtrMemoryPool:: release_shared_ptr (TPointedToClass * to_release) {
_pointer_queue.enqueue (to_release);
}

model
std :: shared_ptr make_shared_ptr_from_pool (SharedPtrMemoryPool& pool, Args && ... args) {
std :: shared_ptr retval = pool.get_shared_ptr ();
retval-> rebuild (std :: forward(args) ...);
return retval;
}

#end if