30 #ifndef BIT_MEMORY_BLOCK_ALLOCATORS_STATIC_BLOCK_ALLOCATOR_HPP 31 #define BIT_MEMORY_BLOCK_ALLOCATORS_STATIC_BLOCK_ALLOCATOR_HPP 33 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 35 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 37 #include "detail/named_block_allocator.hpp" 39 #include "../utilities/owner.hpp" 40 #include "../utilities/memory_block.hpp" 41 #include "../utilities/memory_block_cache.hpp" 42 #include "../utilities/pointer_utilities.hpp" 69 template<std::size_t BlockSize,
70 std::size_t Blocks = 1,
71 std::size_t Align =
alignof(std::max_align_t),
75 static_assert( Blocks > 0,
76 "Must have at least one block" );
77 static_assert( is_power_of_two(Align),
78 "Alignment must be a power of two" );
79 static_assert( Blocks == 1 || BlockSize % Align == 0,
80 "Block size must must be an increment of the alignment" );
87 using block_size = std::integral_constant<std::size_t,BlockSize>;
88 using block_alignment = std::integral_constant<std::size_t,Align>;
130 owner<memory_block> allocate_block() noexcept;
135 void deallocate_block( owner<memory_block> block ) noexcept;
145 std::size_t next_block_size()
const noexcept;
160 static constexpr
auto s_storage_size = BlockSize * Blocks;
161 alignas(Align)
static char s_storage[s_storage_size];
171 template<std::size_t BlockSize,
172 std::size_t Blocks = 1,
173 std::size_t Align =
alignof(std::max_align_t),
175 using named_static_block_allocator
181 #include "detail/static_block_allocator.inl" A cache containing an intrinsically linked list of memory_blocks.
This type is used to hold the generic information for a given allocator.
This is a block allocator that distributes blocks of memory stored statically.