30 #ifndef BIT_MEMORY_BLOCK_ALLOCATORS_STACK_BLOCK_ALLOCATOR_HPP 31 #define BIT_MEMORY_BLOCK_ALLOCATORS_STACK_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/allocator_info.hpp" 40 #include "../utilities/macros.hpp" 41 #include "../utilities/memory_block.hpp" 42 #include "../utilities/memory_block_cache.hpp" 43 #include "../utilities/owner.hpp" 44 #include "../utilities/pointer_utilities.hpp" 66 template<std::size_t BlockSize,
67 std::size_t Blocks=1u,
68 std::size_t Align=
alignof(std::max_align_t)>
71 static_assert( Blocks > 0,
72 "Must have at least one block" );
73 static_assert( is_power_of_two(Align),
74 "Alignment must be a power of two" );
75 static_assert( Blocks == 1 || BlockSize % Align == 0,
76 "Block size must must be an increment of the alignment" );
83 using block_size = std::integral_constant<std::size_t,BlockSize>;
84 using block_alignment = std::integral_constant<std::size_t,Align>;
119 owner<memory_block> allocate_block() noexcept;
127 void deallocate_block( owner<memory_block> block ) noexcept;
137 std::size_t next_block_size()
const noexcept;
152 static constexpr
auto s_storage_size = BlockSize * Blocks;
154 alignas(Align)
char m_storage[s_storage_size];
162 template<std::size_t BlockSize,
163 std::size_t Blocks=1,
164 std::size_t Align=
alignof(std::max_align_t)>
170 #include "detail/stack_block_allocator.inl" An allocator with automatic storage reclamation.
A cache containing an intrinsically linked list of memory_blocks.
This type is used to hold the generic information for a given allocator.