From def67bba57e7cfdf9942bc2c88a4ce484963f9d2 Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Fri, 6 Sep 2024 23:22:18 +0200 Subject: maybe_uninit --- asl/layout.hpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 asl/layout.hpp (limited to 'asl/layout.hpp') diff --git a/asl/layout.hpp b/asl/layout.hpp new file mode 100644 index 0000000..5141456 --- /dev/null +++ b/asl/layout.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "asl/integers.hpp" +#include "asl/meta.hpp" + +namespace asl +{ + +template +inline constexpr int64_t size_of = static_cast(sizeof(T)); + +template +inline constexpr int64_t align_of = static_cast(alignof(T)); + +struct layout +{ + int64_t size; + int64_t align; + + constexpr bool operator==(const layout&) const = default; + + template + static constexpr layout of() + { + return layout{ size_of, align_of }; + } +}; + +} // namespace asl -- cgit