diff --git a/libcxx/include/variant b/libcxx/include/variant --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -1638,7 +1638,7 @@ # if _LIBCPP_STD_VER > 17 -template +template requires (three_way_comparable<_Types> && ...) _LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t...> operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) { using __variant_detail::__visitation::__variant; diff --git a/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp b/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp --- a/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.relops/three_way.pass.cpp @@ -173,12 +173,8 @@ static_assert( has_three_way_op); static_assert( has_three_way_op>); -// variants containing types with unavailable operator== still exist but will -// generate a compilation error if their operator== is invoked, so the variant -// type here participates when asked for operator== and operator<=> even though -// it would actually fail. static_assert(!three_way_comparable); -static_assert( three_way_comparable>); +static_assert(!three_way_comparable>); static_assert( has_three_way_op); static_assert( has_three_way_op>);