diff options
author | Tom <tomut@yahoo.com> | 2021-02-07 15:30:23 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-08 18:00:38 +0100 |
commit | 1d843c46eb6bfc62e99040c59ee870d4d47db0ba (patch) | |
tree | e2209f3c6e53e5c8c838788355cdf92190329ca4 | |
parent | 79bab28f5ef0665f00ad85ae959276338ad0f40c (diff) | |
download | serenity-1d843c46eb6bfc62e99040c59ee870d4d47db0ba.zip |
Kernel: KResultOr can use the same storage as the object for the error
Since it can only hold either an object or an error code, we can share
the same storage to hold either.
-rw-r--r-- | Kernel/KResult.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Kernel/KResult.h b/Kernel/KResult.h index b6988f1364..aaafe7d052 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -172,8 +172,10 @@ public: } private: - alignas(T) char m_storage[sizeof(T)]; - KResult m_error; + union { + alignas(T) char m_storage[sizeof(T)]; + KResult m_error; + }; bool m_is_error { false }; bool m_have_storage { false }; }; |