From 838c4b9a45a50f252c7b20d14570b0b7463709ab Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic <steven.lerouzic@gmail.com> Date: Wed, 8 Jan 2025 23:40:52 +0100 Subject: Finish work on hashing probably --- asl/status_or.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'asl/status_or.hpp') diff --git a/asl/status_or.hpp b/asl/status_or.hpp index 04fcc4a..b8b2881 100644 --- a/asl/status_or.hpp +++ b/asl/status_or.hpp @@ -2,6 +2,7 @@ #include "asl/status.hpp" #include "asl/maybe_uninit.hpp" +#include "asl/hash.hpp" namespace asl { @@ -122,9 +123,6 @@ public: constexpr bool ok() const { return m_status.ok(); } - // NOLINTNEXTLINE(*-explicit-conversions) - constexpr operator bool() const { return m_status; } - constexpr status_code code() const { return m_status.code(); } constexpr string_view message() const { return m_status.message(); } @@ -161,6 +159,17 @@ public: { return ok() ? ASL_MOVE(value()) : static_cast<T>(ASL_FWD(other_value)); } + + template<typename H> + requires hashable<T> + friend H AslHashValue(H h, const status_or& s) + { + if (s.ok()) + { + return H::combine(ASL_MOVE(h), s.m_status, s.value()); + } + return H::combine(ASL_MOVE(h), s.m_status); + } }; template<typename T> -- cgit