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.
This commit is contained in:
Tom 2021-02-07 15:30:23 -07:00 committed by Andreas Kling
parent 79bab28f5e
commit 1d843c46eb
Notes: sideshowbarker 2024-07-18 22:31:28 +09:00

View file

@ -172,8 +172,10 @@ public:
} }
private: private:
alignas(T) char m_storage[sizeof(T)]; union {
KResult m_error; alignas(T) char m_storage[sizeof(T)];
KResult m_error;
};
bool m_is_error { false }; bool m_is_error { false };
bool m_have_storage { false }; bool m_have_storage { false };
}; };