105 if (numItems > std::numeric_limits<size_t>::max() /
sizeof(T)) {
109 if ((mIndex + numItems) > mSize) {
114 size_t alignment =
alignof(T);
115 mIndex = (mIndex + alignment - 1) & ~(alignment - 1);
117 T *ptr = &mBlock[mIndex];
125 mBlock =
new T[size];
149 return (mSize - mIndex);
#define CPPCORE_NONE_COPYING(name)
This macro marks a class a not copyable.
A simple scratch allocator.
size_t capacity() const
Returns the capacity of items in the pool allocator.
void clear()
Will clear the pool, memory will be deallocated.
T * alloc(size_t numItems)
Will allocate the number of items.
size_t freeMem() const
Will return the free memory in the pool in bytes.
size_t reservedMem() const
Will return the reserved memory in bytes.
TScratchAllocator()=default
The default class constructor.
void reserve(size_t size)
Will reserve the pool.
TScratchAllocator(size_t numItems)
The class constructor with the pool size.
~TScratchAllocator()
The class destructor.
TScratchAllocator< char > ScratchAllocator