37#include <foonathan/memory/aligned_allocator.hpp>
38#include <foonathan/memory/deleter.hpp>
39#include <foonathan/memory/fallback_allocator.hpp>
40#include <foonathan/memory/iteration_allocator.hpp>
41#include <foonathan/memory/joint_allocator.hpp>
42#include <foonathan/memory/memory_arena.hpp>
43#include <foonathan/memory/memory_pool.hpp>
44#include <foonathan/memory/memory_pool_collection.hpp>
45#include <foonathan/memory/memory_resource_adapter.hpp>
46#include <foonathan/memory/segregator.hpp>
47#include <foonathan/memory/static_allocator.hpp>
48#include <foonathan/memory/std_allocator.hpp>
49#include <foonathan/memory/temporary_allocator.hpp>
50#include <foonathan/memory/tracking.hpp>
52#include <scoped_allocator>
60 template<
typename Allocator>
using AllocatorTraits = foonathan::memory::allocator_traits<Allocator>;
69 [[nodiscard]]
static void*
allocate_node(std::size_t size, std::size_t alignment);
71 std::size_t alignment)
noexcept;
73 [[nodiscard]]
static void*
allocate_array(std::size_t count, std::size_t size,
74 std::size_t alignment);
76 std::size_t alignment)
noexcept;
83 template<
class StoragePolicy,
class Mutex>
using AllocatorStorage = foonathan::memory::allocator_storage<StoragePolicy, Mutex>;
86 template<
class RawAllocator>
using DirectStorage = foonathan::memory::direct_storage<RawAllocator>;
89 template<
class RawAllocator>
using ReferenceStorage = foonathan::memory::reference_storage<RawAllocator>;
92 template<
class RawAllocator>
using AllocatorReference = foonathan::memory::allocator_reference<RawAllocator>;
101 template<
class RawAllocator>
using AllocatorAdapter = foonathan::memory::allocator_adapter<RawAllocator>;
104 template<
class RawAllocator,
class Mutex = std::mutex>
using ThreadSafeAllocator = foonathan::memory::thread_safe_allocator<RawAllocator, Mutex>;
107 template<
class RawAllocator>
using AlignedAllocator = foonathan::memory::aligned_allocator<RawAllocator>;
116 template<
class Default,
class Fallback>
using FallbackAllocator = foonathan::memory::fallback_allocator<Default, Fallback>;
122 template<std::
size_t N,
class BlockOrRawAllocator = DefaultAllocator>
126 template<
class BlockOrRawAllocator = DefaultAllocator>
using DoubleFrameAllocator = foonathan::memory::double_frame_allocator<BlockOrRawAllocator>;
132 template<
class BlockAllocator = DefaultAllocator,
bool Cached = true>
using MemoryArena = foonathan::memory::memory_arena<BlockAllocator, Cached>;
135 template<
class RawAllocator = DefaultAllocator,
unsigned Num = 2,
unsigned Den = 1>
139 template<
class RawAllocator = DefaultAllocator>
using FixedBlockAllocator = foonathan::memory::fixed_block_allocator<RawAllocator>;
151 template<
typename PoolType = foonathan::memory::node_pool,
class BlockOrRawAllocator = DefaultAllocator>
152 using MemoryPool = foonathan::memory::memory_pool<PoolType, BlockOrRawAllocator>;
154 namespace BucketDistribution {
163 template<
class PoolType,
class BucketDistribution,
class BlockOrRawAllocator = DefaultAllocator>
164 using MemoryPoolCollection = foonathan::memory::memory_pool_collection<PoolType, BucketDistribution, BlockOrRawAllocator>;
167 template<
class PoolType = NodePool,
class BlockOrRawAllocator = DefaultAllocator>
168 using BucketAllocator = foonathan::memory::bucket_allocator<PoolType, BlockOrRawAllocator>;
171 template<
class BlockOrRawAllocator = DefaultAllocator>
using MemoryStack = foonathan::memory::memory_stack<BlockOrRawAllocator>;
174 template<
class Stack = MemoryStack<>>
using MemoryStackScope = foonathan::memory::memory_stack_raii_unwind<Stack>;
186 template<
class Segregatable,
class RawAllocator>
using BinarySegregator = foonathan::memory::binary_segregator<Segregatable, RawAllocator>;
198 template<
class Tracker,
class RawAllocator>
using TrackedAllocator = foonathan::memory::tracked_allocator<Tracker, RawAllocator>;
201 template<
class Tracker,
class BlockOrRawAllocator>
using TrackedBlockAllocator = foonathan::memory::tracked_block_allocator<Tracker, BlockOrRawAllocator>;
204 template<
class Tracker,
class BlockOrRawAllocator>
214 template<
typename T,
class RawAllocator>
using JointPtr = foonathan::memory::joint_ptr<T, RawAllocator>;
217 template<
typename T>
using JointArray = foonathan::memory::joint_array<T>;
220 template<
typename T,
class RawAllocator>
using JointAllocator = foonathan::memory::joint_allocator;
225 template<
typename T,
class RawAllocator = DefaultAllocator>
using StdAllocator = foonathan::memory::std_allocator<T, RawAllocator>;
231 template<
class RawAllocator>
using MemoryResourceAdapter = foonathan::memory::memory_resource_adapter<RawAllocator>;
237 template<
typename Type,
class RawAllocator>
using AllocatorDeallocator = foonathan::memory::allocator_deallocator<Type, RawAllocator>;
240 template<
typename BaseType,
class RawAllocator>
244 template<
typename Type,
class RawAllocator>
using AllocatorDeleter = foonathan::memory::allocator_deleter<Type, RawAllocator>;
247 template<
typename BaseType,
class RawAllocator>
279 using foonathan::memory::allocate_joint;
280 using foonathan::memory::clone_joint;
281 using foonathan::memory::get_temporary_stack;
282 using foonathan::memory::make_aligned_allocator;
283 using foonathan::memory::make_allocator_adapter;
284 using foonathan::memory::make_allocator_reference;
285 using foonathan::memory::make_any_allocator_reference;
286 using foonathan::memory::make_any_std_allocator;
287 using foonathan::memory::make_block_allocator;
288 using foonathan::memory::make_deeply_tracked_allocator;
289 using foonathan::memory::make_segregator;
290 using foonathan::memory::make_std_allocator;
291 using foonathan::memory::make_thread_safe_allocator;
292 using foonathan::memory::make_tracked_allocator;
293 using foonathan::memory::threshold;
328 template<std::
size_t N, std::
size_t Alignment = alignof(std::max_align_t)>
class Arena {
338 template<std::
size_t ReqAlign>
char*
allocate(std::size_t
n);
346 static std::size_t
align_up(
const std::size_t
n)
noexcept {
return (
n + (Alignment - 1)) & ~(Alignment - 1); }
351 static_assert(
ReqAlign <= Alignment,
"alignment is too small for this arena");
352 assert(pointer_in_buffer(mPointer) &&
"short_alloc has outlived arena");
360 static_assert(Alignment <=
alignof(std::max_align_t),
362 "alignment that is larger than alignof(std::max_align_t), and "
363 "cannot be guaranteed by normal operator new");
368 assert(pointer_in_buffer(mPointer) &&
"short_alloc has outlived arena");
369 if(pointer_in_buffer(p)) {
371 if(p +
n == mPointer) {
379 template<
class T, std::
size_t N, std::
size_t Align = alignof(std::max_align_t)>
class ShortAllocator {
404 template<
class T1, std::
size_t N1, std::
size_t A1,
class U, std::
size_t M, std::
size_t A2>
410 template<
class T, std::
size_t N, std::
size_t A1,
class U, std::
size_t M, std::
size_t A2>
415 template<
class T, std::
size_t N, std::
size_t A1,
class U, std::
size_t M, std::
size_t A2>
422[[nodiscard]]
void*
operator new(std::size_t count, std::align_val_t alignment);
423[[nodiscard]]
void*
operator new(std::size_t count);
424[[nodiscard]]
void*
operator new(std::size_t count, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
425[[nodiscard]]
void*
operator new(std::size_t count,
const std::nothrow_t&)
noexcept;
427[[nodiscard]]
void*
operator new[](std::size_t count, std::align_val_t alignment);
428[[nodiscard]]
void*
operator new[](std::size_t count);
429[[nodiscard]]
void*
operator new[](std::size_t count, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
430[[nodiscard]]
void*
operator new[](std::size_t count,
const std::nothrow_t&)
noexcept;
432void operator delete(
void* ptr, std::align_val_t alignment)
noexcept;
433void operator delete(
void* ptr)
noexcept;
434void operator delete(
void* ptr, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
435void operator delete(
void* ptr,
const std::nothrow_t&)
noexcept;
437void operator delete(
void* ptr, std::size_t sz, std::align_val_t alignment)
noexcept;
438void operator delete(
void* ptr, std::size_t sz)
noexcept;
439void operator delete(
void* ptr, std::size_t sz, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
440void operator delete(
void* ptr, std::size_t sz,
const std::nothrow_t&)
noexcept;
442void operator delete[](
void* ptr, std::align_val_t alignment)
noexcept;
443void operator delete[](
void* ptr)
noexcept;
444void operator delete[](
void* ptr,
const std::nothrow_t& tag)
noexcept;
445void operator delete[](
void* ptr, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
447void operator delete[](
void* ptr, std::size_t sz, std::align_val_t alignment)
noexcept;
448void operator delete[](
void* ptr, std::size_t sz)
noexcept;
449void operator delete[](
void* ptr, std::size_t sz,
const std::nothrow_t& tag)
noexcept;
450void operator delete[](
void* ptr, std::size_t sz, std::align_val_t alignment,
const std::nothrow_t&)
noexcept;
452template<>
class foonathan::memory::allocator_traits<
CeresEngine::DefaultAllocator> {
455 using is_stateful = std::integral_constant<bool, false>;
457 static void* allocate_node(allocator_type& state,
const std::size_t size,
const std::size_t alignment) {
return state.allocate_node(size, alignment); }
458 static void deallocate_node(allocator_type& state,
void* node,
const std::size_t size,
const std::size_t alignment)
noexcept {
459 state.deallocate_node(node, size, alignment);
462 static void* allocate_array(allocator_type& state,
const std::size_t count,
const std::size_t size,
const std::size_t alignment) {
463 return state.allocate_array(count, size, alignment);
465 static void deallocate_array(allocator_type& state,
void* array,
const std::size_t count,
const std::size_t size,
const std::size_t alignment)
noexcept {
466 state.deallocate_array(array, count, size, alignment);
469 static std::size_t max_node_size(
const allocator_type& state) {
return state.max_node_size(); }
470 static std::size_t max_array_size(
const allocator_type& state) {
return state.max_array_size(); }
471 static std::size_t max_alignment(
const allocator_type& state) {
return state.max_alignment(); }
#define CE_EXPORT
The CE_EXPORT macro marks a symbol as exported in a DLL.
Definition Macros.hpp:229
Definition Allocator.hpp:328
Arena() noexcept
Definition Allocator.hpp:334
std::size_t used() const noexcept
Definition Allocator.hpp:342
static constexpr std::size_t size() noexcept
Definition Allocator.hpp:341
char mBuffer[N]
Definition Allocator.hpp:329
char * allocate(std::size_t n)
Definition Allocator.hpp:350
void reset() noexcept
Definition Allocator.hpp:343
Arena(const Arena &)=delete
~Arena()
Definition Allocator.hpp:333
static std::size_t align_up(const std::size_t n) noexcept
Definition Allocator.hpp:346
char * mPointer
Definition Allocator.hpp:330
Arena & operator=(const Arena &)=delete
void deallocate(char *p, std::size_t n) noexcept
Definition Allocator.hpp:367
bool pointer_in_buffer(char *p) noexcept
Definition Allocator.hpp:347
Definition Allocator.hpp:379
ShortAllocator(ArenaType &a) noexcept
Definition Allocator.hpp:396
ShortAllocator & operator=(const ShortAllocator &)=delete
friend bool operator==(const ShortAllocator< T1, N1, A1 > &x, const ShortAllocator< U, M, A2 > &y) noexcept
T ValueType
Definition Allocator.hpp:384
ValueType value_type
Definition Allocator.hpp:387
static auto constexpr size
Definition Allocator.hpp:382
void deallocate(T *p, const std::size_t n) noexcept
Definition Allocator.hpp:402
ShortAllocator(const ShortAllocator< U, N, alignment > &a) noexcept
Definition Allocator.hpp:397
ArenaType mArena
Definition Allocator.hpp:390
ShortAllocator(const ShortAllocator &)=default
static auto constexpr alignment
Definition Allocator.hpp:381
T * allocate(const std::size_t n)
Definition Allocator.hpp:401
foonathan::memory::identity_buckets IdentityBuckets
Definition Allocator.hpp:156
foonathan::memory::log2_buckets Log2Buckets
Definition Allocator.hpp:159
Definition Application.hpp:19
foonathan::memory::static_block_allocator StaticBlockAllocator
Definition Allocator.hpp:195
foonathan::memory::bucket_allocator< PoolType, BlockOrRawAllocator > BucketAllocator
Definition Allocator.hpp:168
foonathan::memory::composable_allocator_traits< Allocator > ComposableAllocatorTraits
Definition Allocator.hpp:63
foonathan::memory::node_pool NodePool
Definition Allocator.hpp:142
foonathan::memory::bad_array_size BadArraySizeError
Definition Allocator.hpp:272
foonathan::memory::tracked_allocator< Tracker, RawAllocator > TrackedAllocator
Definition Allocator.hpp:198
foonathan::memory::allocator_adapter< RawAllocator > AllocatorAdapter
Definition Allocator.hpp:101
foonathan::memory::allocator_polymorphic_deallocator< BaseType, RawAllocator > AllocatorPolymorphicDeallocator
Definition Allocator.hpp:241
foonathan::memory::bad_alignment BadAlignmentError
Definition Allocator.hpp:275
foonathan::memory::allocator_traits< Allocator > AllocatorTraits
Definition Allocator.hpp:60
foonathan::memory::tracked_block_allocator< Tracker, BlockOrRawAllocator > TrackedBlockAllocator
Definition Allocator.hpp:201
foonathan::memory::out_of_fixed_memory OutOfFixedMemoryError
Definition Allocator.hpp:263
foonathan::memory::small_node_pool SmallNodePool
Definition Allocator.hpp:148
foonathan::memory::any_allocator_reference AnyAllocatorReference
Definition Allocator.hpp:98
foonathan::memory::std_allocator< T, RawAllocator > StdAllocator
Definition Allocator.hpp:225
foonathan::memory::allocator_storage< StoragePolicy, Mutex > AllocatorStorage
Definition Allocator.hpp:83
foonathan::memory::memory_block MemoryBlock
Definition Allocator.hpp:57
foonathan::memory::allocator_deleter< Type, RawAllocator > AllocatorDeleter
Definition Allocator.hpp:244
foonathan::memory::temporary_allocator TemporaryAllocator
Definition Allocator.hpp:110
foonathan::memory::memory_arena< BlockAllocator, Cached > MemoryArena
Definition Allocator.hpp:132
bool operator!=(const ShortAllocator< T, N, A1 > &x, const ShortAllocator< U, M, A2 > &y) noexcept
Definition Allocator.hpp:416
foonathan::memory::any_std_allocator< T > AnyStdAllocator
Definition Allocator.hpp:228
foonathan::memory::array_pool ArrayPool
Definition Allocator.hpp:145
foonathan::memory::growing_block_allocator< RawAllocator, Num, Den > GrowingBlockAllocator
Definition Allocator.hpp:136
foonathan::memory::iteration_allocator< N, BlockOrRawAllocator > IterationAllocator
Definition Allocator.hpp:123
foonathan::memory::bad_node_size BadNodeSizeError
Definition Allocator.hpp:269
foonathan::memory::heap_allocator HeapAllocator
Definition Allocator.hpp:119
foonathan::memory::virtual_memory_allocator VirtualMemoryAllocator
Definition Allocator.hpp:208
foonathan::memory::memory_resource_adapter< RawAllocator > MemoryResourceAdapter
Definition Allocator.hpp:231
foonathan::memory::allocator_info AllocatorInfo
Definition Allocator.hpp:257
foonathan::memory::binary_segregator< Segregatable, RawAllocator > BinarySegregator
Definition Allocator.hpp:186
foonathan::memory::malloc_allocator MallocAllocator
Definition Allocator.hpp:129
foonathan::memory::direct_storage< RawAllocator > DirectStorage
Definition Allocator.hpp:86
bool operator==(const ShortAllocator< T, N, A1 > &x, const ShortAllocator< U, M, A2 > &y) noexcept
Definition Allocator.hpp:411
DefaultAllocator & gDefaultAllocator()
foonathan::memory::static_allocator_storage< Size > StaticAllocatorStorage
Definition Allocator.hpp:189
foonathan::memory::joint_allocator JointAllocator
Definition Allocator.hpp:220
foonathan::memory::memory_stack_raii_unwind< Stack > MemoryStackScope
Definition Allocator.hpp:174
foonathan::memory::deeply_tracked_block_allocator< Tracker, BlockOrRawAllocator > DeeplyTrackedBlockAllocator
Definition Allocator.hpp:205
foonathan::memory::allocator_polymorphic_deleter< BaseType, RawAllocator > AllocatorPolymorphicDeleter
Definition Allocator.hpp:248
foonathan::memory::joint_ptr< T, RawAllocator > JointPtr
Definition Allocator.hpp:214
foonathan::memory::reference_storage< RawAllocator > ReferenceStorage
Definition Allocator.hpp:89
foonathan::memory::memory_pool_collection< PoolType, BucketDistribution, BlockOrRawAllocator > MemoryPoolCollection
Definition Allocator.hpp:164
foonathan::memory::fixed_block_allocator< RawAllocator > FixedBlockAllocator
Definition Allocator.hpp:139
foonathan::memory::any_allocator AnyAllocator
Definition Allocator.hpp:95
foonathan::memory::joint_array< T > JointArray
Definition Allocator.hpp:217
foonathan::memory::memory_pool< PoolType, BlockOrRawAllocator > MemoryPool
Definition Allocator.hpp:152
foonathan::memory::allocator_deallocator< Type, RawAllocator > AllocatorDeallocator
Definition Allocator.hpp:237
foonathan::memory::threshold_segregatable< RawAllocator > ThresholdSegregatable
Definition Allocator.hpp:180
foonathan::memory::memory_stack< BlockOrRawAllocator > MemoryStack
Definition Allocator.hpp:171
foonathan::memory::null_allocator NullAllocator
Definition Allocator.hpp:183
foonathan::memory::double_frame_allocator< BlockOrRawAllocator > DoubleFrameAllocator
Definition Allocator.hpp:126
foonathan::memory::out_of_memory OutOfMemoryError
Definition Allocator.hpp:260
foonathan::memory::static_allocator StaticAllocator
Definition Allocator.hpp:192
foonathan::memory::fallback_allocator< Default, Fallback > FallbackAllocator
Definition Allocator.hpp:116
foonathan::memory::allocator_reference< RawAllocator > AllocatorReference
Definition Allocator.hpp:92
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
foonathan::memory::aligned_allocator< RawAllocator > AlignedAllocator
Definition Allocator.hpp:107
std::scoped_allocator_adaptor< OuterAlloc, InnerAlloc... > ScopedAllocatorAdaptor
The ScopedAllocatorAdaptor class template is an allocator which can be used with multilevel container...
Definition Allocator.hpp:324
foonathan::memory::temporary_stack_initializer TemporaryStackInitializer
Definition Allocator.hpp:113
foonathan::memory::new_allocator NewAllocator
Definition Allocator.hpp:177
foonathan::memory::thread_safe_allocator< RawAllocator, Mutex > ThreadSafeAllocator
Definition Allocator.hpp:104
foonathan::memory::virtual_block_allocator VirtualBlockAllocator
Definition Allocator.hpp:211
foonathan::memory::memory_resource_allocator MemoryResourceAllocator
Definition Allocator.hpp:234
foonathan::memory::bad_allocation_size BadAllocationSizeError
Definition Allocator.hpp:266
Definition Allocator.hpp:66
static std::size_t max_node_size()
static std::size_t max_array_size()
static void * allocate_node(std::size_t size, std::size_t alignment)
std::integral_constant< bool, false > is_stateful
Definition Allocator.hpp:67
static void * allocate_array(std::size_t count, std::size_t size, std::size_t alignment)
static void deallocate_node(void *node, std::size_t size, std::size_t alignment) noexcept
static void deallocate_array(void *ptr, std::size_t count, std::size_t size, std::size_t alignment) noexcept
static std::size_t max_alignment()
Definition Allocator.hpp:399