#include <AllocatorWrapper.h>
|
|
| xiiLocalAllocatorWrapper (xiiAllocator *pAllocator) |
|
void | Reset () |
Helper function to facilitate setting the allocator on member containers of a class Allocators can be either template arguments or a ctor parameter. Using the ctor parameter requires the class ctor to reference each member container in the initialization list. This can be very tedious. On the other hand, the template variant only support template parameter so you can't simply pass in a member allocator. This class solves this problem provided the following rules are followed:
- The xiiAllocator must be the declared at the earliest in the class, before any container.
- The xiiLocalAllocatorWrapper should be declared right afterwards.
- Any container needs to be declared below these two and must include the xiiLocalAllocatorWrapper as a template argument to the allocator.
- In the ctor initializer list, init the xiiAllocator first, then the xiiLocalAllocatorWrapper. With this approach all containers can be omitted.
class MyClass
{
MyClass()
: m_SpecialAlloc("MySpecialAlloc")
, m_Wrapper(&m_SpecialAlloc)
{
}
}
Definition Allocator.h:39
Definition DynamicArray.h:84
Definition AllocatorWrapper.h:62
The documentation for this struct was generated from the following files:
- /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/AllocatorWrapper.h
- /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/Implementation/AllocatorWrapper.cpp