Pigweed
 
Loading...
Searching...
No Matches
pw::allocator::Layout Class Reference

#include <layout.h>

Public Member Functions

constexpr Layout (size_t size)
 
constexpr Layout (size_t size, size_t alignment)
 
constexpr Layout Extend (size_t size) const
 
constexpr Layout Align (size_t alignment) const
 
constexpr size_t size () const
 
constexpr size_t alignment () const
 

Static Public Member Functions

template<typename T >
static constexpr std::enable_if_t<!std::is_array_v< T >, LayoutOf ()
 Creates a Layout for the given type.
 
template<typename T >
static constexpr std::enable_if_t< internal::is_bounded_array_v< T >, LayoutOf ()
 Creates a Layout for the given bounded array type, e.g. Foo[kN].
 
template<typename T >
static constexpr std::enable_if_t< internal::is_unbounded_array_v< T >, LayoutOf (size_t count)
 Creates a Layout for the given array type, e.g. Foo[].
 
static constexpr Layout Unwrap (const Result< Layout > &result)
 

Detailed Description

Describes the layout of a block of memory.

Layouts are passed to allocators, and consist of a (possibly padded) size and a power-of-two alignment no larger than the size. Layouts can be constructed for a type T using Layout::Of.

Example:

struct MyStruct {
uint8_t field1[3];
uint32_t field2[3];
};
constexpr Layout layout_for_struct = Layout::Of<MyStruct>();
Definition: layout.h:56

Member Function Documentation

◆ Unwrap()

static constexpr Layout pw::allocator::Layout::Unwrap ( const Result< Layout > &  result)
inlinestaticconstexpr

If the result is okay, returns its contained layout; otherwise, returns a default layout.


The documentation for this class was generated from the following file: