Library of Assembled Shared Sources
lass::util::AllocatorSized< VariableAllocator > Class Template Reference

#include <allocator.h>

Inheritance diagram for lass::util::AllocatorSized< VariableAllocator >:
Collaboration diagram for lass::util::AllocatorSized< VariableAllocator >:

Detailed Description

template<typename VariableAllocator = AllocatorMalloc>
class lass::util::AllocatorSized< VariableAllocator >
  • concept: VariableAllocator

AllocatorSized adds sizeof(size_t) bytes in front of the returned pointer to store the requested block size. Because of that, you can use the simpler form void deallocate(void* mem) to deallocate the memory.

Warning
the fact that this allocator supports void deallocate(void* mem) does NOT mean it implements the FixedAllocator concept, not even partially. So when you use AllocatorSized as a base for an allocator that implements both the VariableAllocator as FixedAllocator concept depending on the base allocator (such as AllocatorStats), the result will be a VariableAllocator. You cannot generally assume you will be able to use void deallocate(void* mem) on the resulting allocator as well. Particularly for AllocatorStats, it is know that this will cause undefined behaviour. However, using AllocatorStats as base AllocatorSized will achieve the desired effect perfectly well, and will cause no problem (= using AllocatorSized on top-level)

it is advised to use AllocatorSized as a top-level allocator. Using AllocatorSized as a base allocator for others can cause undefined behaviour. A notable exception is AllocatorSingleton, it is safe to use that one on top of AllocatorSized.

Definition at line 1207 of file allocator.h.


The documentation for this class was generated from the following file: