1#ifndef NNGN_UTILS_ALLOC_BLOCK_H
2#define NNGN_UTILS_ALLOC_BLOCK_H
30template<
typename H,
typename T =
char>
46 if constexpr(std::is_standard_layout_v<alloc_block::storage>)
53 return offsetof(
S,
data);
58 static constexpr std::size_t
alloc_size(std::size_t
n);
99template<
typename H,
typename T>
104template<
typename H,
typename T>
107 if constexpr(std::is_standard_layout_v<S>)
Non-owning handle to an aggregate header and data block.
Definition block.h:31
T value_type
Definition block.h:35
constexpr storage * data(void)
Pointer to the block.
Definition block.h:68
void free(void)
Frees the block's memory.
Definition block.h:91
static constexpr bool both_trivial
Definition block.h:32
constexpr value_type * get(void)
Pointer to the data block.
Definition block.h:76
void realloc(std::size_t s)
Reallocates the entire block.
Definition block.h:87
static constexpr std::size_t data_offset
Total size of an allocation for n elements.
Definition block.h:45
static constexpr auto from_storage_ptr(void *p)
Constructs a handle to a pre-existing storage block.
Definition block.h:61
static alloc_block alloc(void)
Allocates a block to contain exactly a T.
Definition block.h:81
alloc_block(void *p_)
Constructs from a pointer to the block.
Definition block.h:94
constexpr header_type * header(void)
Pointer to the block header.
Definition block.h:72
static alloc_block alloc(std::size_t s)
Allocates a block to contain s bytes of data.
Definition block.h:84
constexpr const header_type * header(void) const
Pointer to the block header.
Definition block.h:74
static constexpr std::size_t alloc_size(std::size_t n)
Total size of an allocation for n elements.
Definition block.h:100
static constexpr alloc_block from_ptr(T *p)
Offsets p to the beginning of the entire block.
Definition block.h:105
H header_type
Definition block.h:34
constexpr const value_type * get(void) const
Pointer to the data block.
Definition block.h:78
constexpr const storage * data(void) const
Pointer to the block.
Definition block.h:70
alloc_block(void) noexcept=default
Initializes a handle with no associated block.
storage * p
Pointer to the underlying storage, non-owning.
Definition block.h:96
local n
Definition dump_lights.lua:5
local data
Definition house0.lua:10
constexpr To byte_cast(From p)
reinterpret_cast restricted to conversions from/to char/uchar.
Definition utils.h:121
#define NNGN_CONTAINER_OF(t, n, p)
Definition utils.h:56
Underlying storage type.
Definition block.h:37
header_type header
Definition block.h:41
value_type data
Definition block.h:42
std::chrono::seconds s
Definition timing.cpp:6
#define S(v0, v1)
Definition vec2.h:16