diff --git a/libcxx/include/compare b/libcxx/include/compare --- a/libcxx/include/compare +++ b/libcxx/include/compare @@ -150,7 +150,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} - template>> + template && is_convertible_v<_Tp, nullptr_t>)>> _CmpUnspecifiedParam(_Tp) = delete; }; diff --git a/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp b/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp --- a/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp @@ -26,13 +26,13 @@ template void test_category(T v) { - TEST_OP(v, ==); // expected-error 18 {{}} - TEST_OP(v, !=); // expected-error 18 {{}} - TEST_OP(v, <); // expected-error 18 {{}} - TEST_OP(v, <=); // expected-error 18 {{}} - TEST_OP(v, >); // expected-error 18 {{}} - TEST_OP(v, >=); // expected-error 18 {{}} - TEST_OP(v, <=>); // expected-error 18 {{}} + TEST_OP(v, ==); // expected-error 12 {{}} + TEST_OP(v, !=); // expected-error 12 {{}} + TEST_OP(v, <); // expected-error 12 {{}} + TEST_OP(v, <=); // expected-error 12 {{}} + TEST_OP(v, >); // expected-error 12 {{}} + TEST_OP(v, >=); // expected-error 12 {{}} + TEST_OP(v, <=>); // expected-error 12 {{}} void(v == 0); void(0 == v); diff --git a/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp @@ -51,6 +51,17 @@ #endif } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& PartialEq = std::partial_ordering::equivalent; + auto& WeakEq = std::weak_ordering::equivalent; + assert(PartialEq == WeakEq); + + auto& StrongEq = std::strong_ordering::equal; + assert(PartialEq == StrongEq); +#endif +} + constexpr bool test_constexpr() { auto& Eq = std::partial_ordering::equivalent; auto& Less = std::partial_ordering::less; @@ -166,6 +177,8 @@ static_assert(std::partial_ordering::unordered == std::partial_ordering::unordered); } + + test_equality(); #endif return true; @@ -174,6 +187,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_constexpr(), "constexpr test failed"); return 0; diff --git a/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp @@ -51,6 +51,17 @@ #endif } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& StrongEq = std::strong_ordering::equal; + auto& PartialEq = std::partial_ordering::equivalent; + assert(StrongEq == PartialEq); + + auto& WeakEq = std::weak_ordering::equivalent; + assert(StrongEq == WeakEq); +#endif +} + constexpr bool test_conversion() { static_assert(std::is_convertible::value, ""); @@ -174,6 +185,8 @@ static_assert(std::strong_ordering::greater == std::strong_ordering::greater); } + + test_equality(); #endif return true; @@ -182,6 +195,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_conversion(), "conversion test failed"); static_assert(test_constexpr(), "constexpr test failed"); diff --git a/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp @@ -71,6 +71,17 @@ return true; } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& WeakEq = std::weak_ordering::equivalent; + auto& PartialEq = std::partial_ordering::equivalent; + assert(WeakEq == PartialEq); + + auto& StrongEq = std::strong_ordering::equal; + assert(WeakEq == StrongEq); +#endif +} + constexpr bool test_constexpr() { auto& Eq = std::weak_ordering::equivalent; auto& Less = std::weak_ordering::less; @@ -156,6 +167,8 @@ std::weak_ordering::equivalent); static_assert(std::weak_ordering::greater == std::weak_ordering::greater); } + + test_equality(); #endif return true; @@ -164,6 +177,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_conversion(), "conversion test failed"); static_assert(test_constexpr(), "constexpr test failed");