12 #include "allocator_base.hpp"
15 inline namespace v_100 {
26 template <
size_t MaxSize,
size_t Alignment = 16>
29 alignas(Alignment)
char _data[MaxSize];
33 bool is_last_used_block(
const block &b)
const noexcept {
34 return (static_cast<char *>(b.
ptr) + b.
length == _p);
40 static const bool supports_truncated_deallocation =
true;
41 static const size_t max_size = MaxSize;
42 static const size_t alignment = Alignment;
49 block allocate(
size_t n) noexcept {
57 if (alignedLength + _p > _data + MaxSize) {
62 result.
length = alignedLength;
68 void deallocate(
block &b) noexcept {
80 if (is_last_used_block(b)) {
81 _p =
static_cast<char *
>(b.
ptr);
86 bool reallocate(
block &b,
size_t n) noexcept {
103 if (is_last_used_block(b)) {
104 if (static_cast<char *>(b.
ptr) + alignedLength <= _data + MaxSize) {
106 _p =
static_cast<char *
>(b.
ptr) + alignedLength;
117 auto newBlock = allocate(alignedLength);
143 if (!is_last_used_block(b)) {
147 if (_p + alignedBytes > _data + MaxSize) {
161 return b && (b.
ptr >= _data && b.
ptr < _data + MaxSize);
180 void *
operator new(size_t) =
delete;
181 void *
operator new[](size_t) =
delete;
182 void operator delete(
void *) =
delete;
183 void operator delete[](
void *) =
delete;
188 template <
size_t MaxSize,
size_t Alignment>
190 template <
size_t MaxSize,
size_t Alignment>
193 using namespace v_100;
bool expand(block &b, size_t delta) noexcept
void deallocate_all() noexcept
void block_copy(const block &source, block &destination) noexcept
size_t length
This describes the length of the reserved bytes.
constexpr size_t round_to_alignment(size_t basis, size_t n) noexcept
void * ptr
This points to the start address of the described memory block.
bool owns(const block &b) const noexcept