18#include "pw_assert/assert.h"
19#include "pw_preprocessor/compiler.h"
20#include "pw_result/result.h"
22namespace pw::allocator {
42 constexpr explicit Layout(
size_t size)
43 :
Layout(size,
alignof(std::max_align_t)) {}
44 constexpr Layout(
size_t size,
size_t alignment)
45 : size_(size), alignment_(alignment) {}
50 return Layout(
sizeof(T),
alignof(T));
56 return result.ok() ? (*result) :
Layout();
59 constexpr Layout Extend(
size_t size)
const {
61 return Layout(size, alignment_);
64 constexpr size_t size()
const {
return size_; }
65 constexpr size_t alignment()
const {
return alignment_; }
72inline bool operator==(
const Layout& lhs,
const Layout& rhs) {
73 return lhs.size() == rhs.size() && lhs.alignment() == rhs.alignment();
76inline bool operator!=(
const Layout& lhs,
const Layout& rhs) {
static constexpr Layout Unwrap(const Result< Layout > &result)
Definition: layout.h:55
static constexpr Layout Of()
Creates a Layout for the given type.
Definition: layout.h:49
#define PW_ADD_OVERFLOW(a, b, out)
Definition: compiler.h:244