The main problem is the allocators that need to know, where to get their memory from. Instead of the current automated version, the alternative might be to give every allocator type a static function which allows setting the memory system or manager. It is stored as a static pointer internally. The problem here is, that the pointer must be settable once for all instances of the template. Maybe this can be realized by using an extra class or template specialization. So every instance calls the GetPointer() method of the extra class or specializes instance.
Important (BUG)
The current implementation using U8 arrays as buffer violates the strict-aliasing rule (link). Use *void and mallocvoid *p = operator new(size);+operator delete(p);(see answer of Ferruccio) instead. To increase and decrease memory addresses of void* have a look at this link
Currently the memory manager is a singleton. Since singletons do have some drawbacks (https://stackoverflow.com/questions/137975/what-is-so-bad-about-singletons) which also manifest in the current unit tests, an alternative approach might be better.
The main problem is the allocators that need to know, where to get their memory from. Instead of the current automated version, the alternative might be to give every allocator type a static function which allows setting the memory system or manager. It is stored as a static pointer internally. The problem here is, that the pointer must be settable once for all instances of the template. Maybe this can be realized by using an extra class or template specialization. So every instance calls the GetPointer() method of the extra class or specializes instance.
Important (BUG) The current implementation using
U8
arrays as buffer violates the strict-aliasing rule (link). Use*void
andmalloc
void *p = operator new(size);
+operator delete(p);
(see answer of Ferruccio) instead. To increase and decrease memory addresses ofvoid*
have a look at this link