From 3491f9aebb5505e923965c1f94dbb64206df7445 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Tue, 2 Jun 2026 16:03:38 +0200 Subject: [PATCH] refactor(result): add value comparison operators --- furlang/include/furlang/result.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/furlang/include/furlang/result.hpp b/furlang/include/furlang/result.hpp index 88940d3..126149d 100644 --- a/furlang/include/furlang/result.hpp +++ b/furlang/include/furlang/result.hpp @@ -199,6 +199,22 @@ public: */ bool operator!=(const result& rhs) const { return !this->operator==(rhs); } + /** + * @brief Compares a result with a value for equality. + * + * @param rhs Value to compare against. + * @return true if the values are equal. + */ + bool operator==(const value_type& rhs) const { return !m_error && !rhs.m_error && m_value.result == rhs; } + + /** + * @brief Compares a result with a value for inequality. + * + * @param rhs Value to compare against. + * @return true if the values are not equal. + */ + bool operator!=(const value_type& rhs) const { return !this->operator==(rhs); } + /** * @brief Returns a reference to value. *