C/C++ API Reference
Loading...
Searching...
No Matches
pw::allocator::Layout Class Reference

Overview

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:64

Public Member Functions

constexpr Layout (size_t size)
 
constexpr Layout (size_t size, size_t alignment)
 
constexpr size_t size () const
 
constexpr size_t alignment () const
 
constexpr Layout Extend (size_t size) const
 Returns a new layout from this object increased by the given size.
 
constexpr Layout Align (size_t alignment) const
 Returns a new layout from this object with at least the given alignment.
 
template<typename T >
constexpr Layout AlignTo () const
 

Static Public Member Functions

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

Member Function Documentation

◆ AlignTo()

template<typename T >
constexpr Layout pw::allocator::Layout::AlignTo ( ) const
inlineconstexpr

Returns a new layout from this object that is at least aligned to the given type.

◆ 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: