Skip to content

Commit 7d1792e

Browse files
committed
fix ambiguous Result comparison operator
1 parent f397080 commit 7d1792e

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

include/common/result.hpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,29 @@ class Result {
180180
return std::move(value);
181181
}
182182

183-
/**
184-
* @brief Equality comparison operator.
185-
* @tparam U Type of the other result's value.
186-
* @tparam Es Other result's error types.
187-
* @param other Result to compare with.
188-
* @return true If values are equal.
189-
*/
190-
template<typename U, typename... Es>
191-
requires std::equality_comparable_with<T, U>
192-
constexpr bool operator==(const Result<U, Es...>& other) {
193-
return value == other.value;
194-
}
195-
196183
std::variant<std::monostate, Errs...> error; ///< Variant holding an error or monostate.
197184
T value; ///< The stored value (always initialized).
198185
};
199186

187+
/**
188+
* @brief compare Result instances with comparable normal values
189+
*
190+
* @tparam LhsT the normal value type of the left-hand side argument
191+
* @tparam RhsT the normal value type of the right-hand side argument
192+
* @tparam LhsErrs the error value types of the left-hand side argument
193+
* @tparam RhsErrs the error value types of the right-hand side argument
194+
* @param lhs the left-hand side of the expression
195+
* @param rhs the right-hand side of the expression
196+
* @return true if the values are equal
197+
* @return false if the values are not equal
198+
*/
199+
template<typename LhsT, typename RhsT, typename... LhsErrs, typename... RhsErrs>
200+
requires std::equality_comparable_with<LhsT, RhsT>
201+
constexpr bool
202+
operator==(const Result<LhsT, LhsErrs...>& lhs, const Result<RhsT, RhsErrs...>& rhs) {
203+
return lhs.value == rhs.value;
204+
}
205+
200206
/**
201207
* @brief Result specialization for void value type (no stored value).
202208
* @tparam Errs List of possible error types (must inherit from ResultError).

0 commit comments

Comments
 (0)