diff options
author | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-03 12:13:34 +0100 |
---|---|---|
committer | Steven Le Rouzic <steven.lerouzic@gmail.com> | 2025-01-03 12:13:34 +0100 |
commit | 46944ec98688e962e94dcfcf426215f252bf2a87 (patch) | |
tree | 1fb08cbc3cd3dedfe8940dbebe8eb1bf5089ac21 /asl/status.cpp | |
parent | c2d4216695b48dfe6bf7083c11e0a7fcbb671e2e (diff) |
Start work on status
Diffstat (limited to 'asl/status.cpp')
-rw-r--r-- | asl/status.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/asl/status.cpp b/asl/status.cpp index e69de29..ac0b29e 100644 --- a/asl/status.cpp +++ b/asl/status.cpp @@ -0,0 +1,27 @@ +#include "asl/status.hpp" +#include "asl/allocator.hpp" + +using Allocator = asl::DefaultAllocator; +static Allocator g_allocator{}; + +namespace +{ + +struct StatusInternal +{ + asl::string_view msg; + asl::status_code code; +}; + +} // anonymous namespace + +asl::status::status(status_code code, string_view msg) + : m_payload{alloc_new<StatusInternal>(g_allocator, msg, code)} +{} + +asl::status_code asl::status::code_internal() const +{ + ASL_ASSERT(m_payload && (bit_cast<uintptr_t>(m_payload) & 1) == 0); + return reinterpret_cast<const StatusInternal*>(m_payload)->code; +} + |