Expected: Fix operator==(void, void)

Change-Id: I883f05155f0710fc3a9f92a2e33d4f8722159016
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-09-19 08:17:31 +02:00
parent bc1c24eb84
commit f1907836fa
2 changed files with 34 additions and 0 deletions

View File

@@ -2278,6 +2278,14 @@ detail::decay_t<Exp> or_else_impl(Exp &&exp, F &&f) {
#endif
} // namespace detail
template <class E, class F>
constexpr bool operator==(const expected<void, E> &lhs,
const expected<void, F> &rhs) {
return (lhs.has_value() != rhs.has_value())
? false
: (!lhs.has_value() ? lhs.error() == rhs.error() : true);
}
template <class T, class E, class U, class F>
constexpr bool operator==(const expected<T, E> &lhs,
const expected<U, F> &rhs) {
@@ -2292,6 +2300,13 @@ constexpr bool operator!=(const expected<T, E> &lhs,
? true
: (!lhs.has_value() ? lhs.error() != rhs.error() : *lhs != *rhs);
}
template<class E, class F>
constexpr bool operator!=(const expected<void, E> &lhs, const expected<void, F> &rhs)
{
return (lhs.has_value() != rhs.has_value())
? true
: (!lhs.has_value() ? lhs.error() != rhs.error() : false);
}
template <class T, class E, class U>
constexpr bool operator==(const expected<T, E> &x, const U &v) {