diff --git a/Kernel/KResult.h b/Kernel/KResult.h index 168b2825cee..cb457b09f10 100644 --- a/Kernel/KResult.h +++ b/Kernel/KResult.h @@ -47,10 +47,10 @@ public: { } operator int() const { return m_error; } - int error() const { return m_error; } + [[nodiscard]] int error() const { return m_error; } - bool is_success() const { return m_error == 0; } - bool is_error() const { return !is_success(); } + [[nodiscard]] bool is_success() const { return m_error == 0; } + [[nodiscard]] bool is_error() const { return !is_success(); } private: template @@ -115,18 +115,22 @@ public: value().~T(); } - bool is_error() const { return m_is_error; } + [[nodiscard]] bool is_error() const { return m_is_error; } + ALWAYS_INLINE KResult error() const { ASSERT(m_is_error); return m_error; } + KResult result() const { return m_is_error ? KSuccess : m_error; } + ALWAYS_INLINE T& value() { ASSERT(!m_is_error); return *reinterpret_cast(&m_storage); } + ALWAYS_INLINE const T& value() const { ASSERT(!m_is_error);