diff --git a/luna/include/luna/Result.h b/luna/include/luna/Result.h index 4179728a..4a8d2baf 100644 --- a/luna/include/luna/Result.h +++ b/luna/include/luna/Result.h @@ -40,52 +40,52 @@ template class Result { } - bool has_error() + bool has_error() const { return !m_has_value; } - bool has_value() + bool has_value() const { return m_has_value; } - int error() + int error() const { expect(has_error(), "Result::error() called on a Result that holds a value"); return m_error; } - Error release_error() + Error release_error() const { expect(has_error(), "Result::release_error() called on a Result that holds a value"); return {m_error}; } - const char* error_string() + const char* error_string() const { expect(has_error(), "Result::error_string() called on a Result that holds a value"); return ::error_string(m_error); } - T value() + T value() const { expect(has_value(), "Result::value() called on a Result that holds an error"); return m_value.value(); } - T expect_value(const char* reason) + T expect_value(const char* reason) const { expect(has_value(), reason); return m_value.value(); } - T value_or(const T& other) + T value_or(const T& other) const { return m_value.value_or(other); } - bool try_set_value(T& ref) + bool try_set_value(T& ref) const { return m_value.try_set_value(ref); } @@ -127,53 +127,53 @@ template <> class Result { } - bool has_error() + bool has_error() const { return m_has_error; } - bool has_value() + bool has_value() const { return !m_has_error; } - int error() + int error() const { expect(has_error(), "Result::error() called on a Result that holds a value"); return m_error; } - Error release_error() + Error release_error() const { expect(has_error(), "Result::release_error() called on a Result that holds a value"); return {m_error}; } - const char* error_string() + const char* error_string() const { expect(has_error(), "Result::error_string() called on a Result that holds a value"); return ::error_string(m_error); } - void value() + void value() const { expect(has_value(), "Result::value() called on a Result that holds an error"); return; } - void expect_value(const char* reason) + void expect_value(const char* reason) const { expect(has_value(), reason); return; } - void release_value() + void release_value() const { expect(has_value(), "Result::release_value() called on a Result that holds an error"); return; } - void expect_release_value(const char* reason) + void expect_release_value(const char* reason) const { expect(has_value(), reason); return;