From afa1b9ddc9e5ea04f54f39d559bd49992f9c6831 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Thu, 26 Oct 2017 22:01:26 +0100 Subject: [PATCH] Comparisons for unexpected, typo fixes --- expected.hpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/expected.hpp b/expected.hpp index dc6c89d..9bbdb2f 100644 --- a/expected.hpp +++ b/expected.hpp @@ -63,6 +63,26 @@ using enable_if_t = typename std::enable_if::type; operator!=(const unexpected& lhs, const unexpected& rhs) { return lhs.value() != rhs.value(); } + template + constexpr bool + operator<(const unexpected& lhs, const unexpected& rhs) { + return lhs.value() < rhs.value(); + } + template + constexpr bool + operator<=(const unexpected& lhs, const unexpected& rhs) { + return lhs.value() <= rhs.value(); + } + template + constexpr bool + operator>(const unexpected& lhs, const unexpected& rhs) { + return lhs.value() > rhs.value(); + } + template + constexpr bool + operator>=(const unexpected& lhs, const unexpected& rhs) { + return lhs.value() >= rhs.value(); + } struct unexpect_t { unexpect_t() = default; @@ -292,11 +312,11 @@ class expected : private detail::expected_storage_base, private detail::exp static_assert(!std::is_reference::value, "E must not be a reference"); static_assert(!std::is_same::value, "T must not be void"); - T* valptr() { return std::addressof(this->m_value); } + T* valptr() { return std::addressof(this->m_val); } unexpected* errptr() { return std::addressof(this->m_unexpect); } - T& val() { return this->m_value; } + T& val() { return this->m_val; } unexpected& err() { return this->m_unexpect; } - const T& val() const { return this->m_value; } + const T& val() const { return this->m_val; } const unexpected& err() const { return this->m_unexpect; } using storage_base = detail::expected_storage_base;