summaryrefslogtreecommitdiff
path: root/asl/layout.hpp
diff options
context:
space:
mode:
authorSteven Le Rouzic <steven.lerouzic@gmail.com>2024-09-06 23:22:18 +0200
committerSteven Le Rouzic <steven.lerouzic@gmail.com>2024-09-06 23:22:18 +0200
commitdef67bba57e7cfdf9942bc2c88a4ce484963f9d2 (patch)
treea0c2024343151166bebc70440e2adb58c611d409 /asl/layout.hpp
parentaa427cb5fe7564a85703f14f76f854419274decc (diff)
maybe_uninit
Diffstat (limited to 'asl/layout.hpp')
-rw-r--r--asl/layout.hpp29
1 files changed, 29 insertions, 0 deletions
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<typename T>
+inline constexpr int64_t size_of = static_cast<int64_t>(sizeof(T));
+
+template<typename T>
+inline constexpr int64_t align_of = static_cast<int64_t>(alignof(T));
+
+struct layout
+{
+ int64_t size;
+ int64_t align;
+
+ constexpr bool operator==(const layout&) const = default;
+
+ template<is_object T>
+ static constexpr layout of()
+ {
+ return layout{ size_of<T>, align_of<T> };
+ }
+};
+
+} // namespace asl