diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-09-06 23:22:18 +0200 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2024-09-06 23:22:18 +0200 |
commit | def67bba57e7cfdf9942bc2c88a4ce484963f9d2 (patch) | |
tree | a0c2024343151166bebc70440e2adb58c611d409 /asl/layout.hpp | |
parent | aa427cb5fe7564a85703f14f76f854419274decc (diff) |
maybe_uninit
Diffstat (limited to 'asl/layout.hpp')
-rw-r--r-- | asl/layout.hpp | 29 |
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
|