Skip to content

Commit

Permalink
Merge db732a6 into 512eb76
Browse files Browse the repository at this point in the history
  • Loading branch information
Minoru committed Apr 29, 2023
2 parents 512eb76 + db732a6 commit 6e865da
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions 3rd-party/expected.hpp
Expand Up @@ -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)

Expand Down Expand Up @@ -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<T>(0) ){};
Expand Down Expand Up @@ -1002,11 +1002,12 @@ class unexpected_type

// x.x.5.2.4 Swap

template< typename U=E >
nsel_REQUIRES_R( void,
std17::is_swappable<E>::value
std17::is_swappable<U>::value
)
swap( unexpected_type & other ) noexcept (
std17::is_nothrow_swappable<E>::value
std17::is_nothrow_swappable<U>::value
)
{
using std::swap;
Expand Down Expand Up @@ -2164,22 +2165,30 @@ class expected<void, E>

// 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<T1>::value && !std::is_void<T2>::value
)
>
constexpr bool operator==( expected<T1,E1> const & x, expected<T2,E2> 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<T1,E1> const & x, expected<T2,E2> const & y )
template< typename T1, typename E1, typename T2, typename E2
nsel_REQUIRES_T(
std::is_void<T1>::value && std::is_void<T2>::value
)
>
constexpr bool operator==( expected<T1,E1> const & x, expected<T2,E2> const & y )
{
return !(x == y);
return bool(x) != bool(y) ? false : bool(x) || static_cast<bool>( x.error() == y.error() );
}

template< typename E1, typename E2 >
constexpr bool operator==( expected<void,E1> const & x, expected<void,E1> const & y )
template< typename T1, typename E1, typename T2, typename E2 >
constexpr bool operator!=( expected<T1,E1> const & x, expected<T2,E2> const & y )
{
return bool(x) != bool(y) ? false : bool(x) == false ? x.error() == y.error() : true;
return !(x == y);
}

#if nsel_P0323R <= 2
Expand Down Expand Up @@ -2212,13 +2221,21 @@ constexpr bool operator>=( expected<T,E> const & x, expected<T,E> 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<T1>::value
)
>
constexpr bool operator==( expected<T1,E1> 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<T1>::value
)
>
constexpr bool operator==(T2 const & v, expected<T1,E1> const & x )
{
return bool(x) ? v == *x : false;
Expand Down

0 comments on commit 6e865da

Please sign in to comment.