From db732a6f6bd17c210281ba8ac4009d36829388bf Mon Sep 17 00:00:00 2001 From: Alexander Batischev Date: Sat, 29 Apr 2023 17:24:30 +0300 Subject: [PATCH] Update expected-lite to 0.6.3 --- 3rd-party/expected.hpp | 45 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/3rd-party/expected.hpp b/3rd-party/expected.hpp index 388f3f13c..adf375bb5 100644 --- a/3rd-party/expected.hpp +++ b/3rd-party/expected.hpp @@ -14,7 +14,7 @@ #define expected_lite_MAJOR 0 #define expected_lite_MINOR 6 -#define expected_lite_PATCH 2 +#define expected_lite_PATCH 3 #define expected_lite_VERSION expected_STRINGIFY(expected_lite_MAJOR) "." expected_STRINGIFY(expected_lite_MINOR) "." expected_STRINGIFY(expected_lite_PATCH) @@ -405,7 +405,7 @@ struct is_nothrow_swappable }; } // namespace detail -// is [nothow] swappable: +// is [nothrow] swappable: template< typename T > struct is_swappable : decltype( detail::is_swappable::test(0) ){}; @@ -1002,11 +1002,12 @@ class unexpected_type // x.x.5.2.4 Swap + template< typename U=E > nsel_REQUIRES_R( void, - std17::is_swappable::value + std17::is_swappable::value ) swap( unexpected_type & other ) noexcept ( - std17::is_nothrow_swappable::value + std17::is_nothrow_swappable::value ) { using std::swap; @@ -2164,22 +2165,30 @@ class expected // x.x.4.6 expected<>: comparison operators -template< typename T1, typename E1, typename T2, typename E2 > +template< typename T1, typename E1, typename T2, typename E2 + nsel_REQUIRES_T( + !std::is_void::value && !std::is_void::value + ) +> constexpr bool operator==( expected const & x, expected const & y ) { - return bool(x) != bool(y) ? false : bool(x) == false ? x.error() == y.error() : *x == *y; + return bool(x) != bool(y) ? false : bool(x) ? *x == *y : x.error() == y.error(); } -template< typename T1, typename E1, typename T2, typename E2 > -constexpr bool operator!=( expected const & x, expected const & y ) +template< typename T1, typename E1, typename T2, typename E2 + nsel_REQUIRES_T( + std::is_void::value && std::is_void::value + ) +> +constexpr bool operator==( expected const & x, expected const & y ) { - return !(x == y); + return bool(x) != bool(y) ? false : bool(x) || static_cast( x.error() == y.error() ); } -template< typename E1, typename E2 > -constexpr bool operator==( expected const & x, expected const & y ) +template< typename T1, typename E1, typename T2, typename E2 > +constexpr bool operator!=( expected const & x, expected const & y ) { - return bool(x) != bool(y) ? false : bool(x) == false ? x.error() == y.error() : true; + return !(x == y); } #if nsel_P0323R <= 2 @@ -2212,13 +2221,21 @@ constexpr bool operator>=( expected const & x, expected const & y ) // x.x.4.7 expected: comparison with T -template< typename T1, typename E1, typename T2 > +template< typename T1, typename E1, typename T2 + nsel_REQUIRES_T( + !std::is_void::value + ) +> constexpr bool operator==( expected const & x, T2 const & v ) { return bool(x) ? *x == v : false; } -template< typename T1, typename E1, typename T2 > +template< typename T1, typename E1, typename T2 + nsel_REQUIRES_T( + !std::is_void::value + ) +> constexpr bool operator==(T2 const & v, expected const & x ) { return bool(x) ? v == *x : false;