[libcxx] removes operator!= and globally guards against no spaceship operator
* `operator!=` isn't in the spec
* `<compare>` is designed to work with `operator<=>` so it doesn't
really make sense to have `operator<=>`-less friendly sections.
Depends on D100283.
Differential Revision: https://reviews.llvm.org/D100342
NOKEYCHECK=True
GitOrigin-RevId: 20506fb1f361e41012506c6c252fd690541fc708
diff --git a/include/compare b/include/compare
index ff3469d..0a2b3d0 100644
--- a/include/compare
+++ b/include/compare
@@ -129,8 +129,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if _LIBCPP_STD_VER > 17
-
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR)
// exposition only
enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
__zero = 0,
@@ -184,24 +183,19 @@
// comparisons
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
-#endif
private:
_ValueT __value_;
@@ -234,10 +228,6 @@
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return __v.__is_ordered() && 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
return __v.__is_ordered() && 0 < __v.__value_;
}
@@ -255,16 +245,6 @@
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
- return !__v.__is_ordered() || __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
- return !__v.__is_ordered() || __v.__value_ != 0;
-}
-
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-_LIBCPP_INLINE_VISIBILITY
constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
return __v;
}
@@ -272,7 +252,6 @@
constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
class weak_ordering {
using _ValueT = signed char;
@@ -295,24 +274,19 @@
// comparisons
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default;
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
-#endif
private:
_ValueT __value_;
@@ -327,10 +301,6 @@
return __v.__value_ == 0;
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
return __v.__value_ < 0;
}
@@ -347,14 +317,6 @@
return __v.__value_ >= 0;
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
- return 0 != __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
return 0 < __v.__value_;
}
@@ -371,7 +333,6 @@
return 0 >= __v.__value_;
}
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY
constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
return __v;
@@ -380,8 +341,6 @@
constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
-
class strong_ordering {
using _ValueT = signed char;
@@ -411,24 +370,19 @@
// comparisons
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
- _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default;
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
_LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
-#endif
private:
_ValueT __value_;
@@ -444,10 +398,6 @@
return __v.__value_ == 0;
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
- return __v.__value_ != 0;
-}
-_LIBCPP_INLINE_VISIBILITY
constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
return __v.__value_ < 0;
}
@@ -464,14 +414,6 @@
return __v.__value_ >= 0;
}
_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 == __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
-constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
- return 0 != __v.__value_;
-}
-_LIBCPP_INLINE_VISIBILITY
constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
return 0 < __v.__value_;
}
@@ -488,7 +430,6 @@
return 0 >= __v.__value_;
}
-#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
_LIBCPP_INLINE_VISIBILITY
constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
return __v;
@@ -497,7 +438,6 @@
constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
}
-#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
// named comparison functions
_LIBCPP_INLINE_VISIBILITY
@@ -582,7 +522,7 @@
template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
-#endif // _LIBCPP_STD_VER > 17
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR)
_LIBCPP_END_NAMESPACE_STD
diff --git a/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp b/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp
index fc21c03..c0fe4cb 100644
--- a/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp
+++ b/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp
@@ -8,6 +8,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: apple-clang-9, apple-clang-10, apple-clang-11, apple-clang-12.0.0
// <compare>
diff --git a/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp b/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
index c473073..0b5169f 100644
--- a/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
+++ b/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: apple-clang-9, apple-clang-10, apple-clang-11, apple-clang-12.0.0
// <compare>
diff --git a/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp b/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
index 40ffb35..e8b9733 100644
--- a/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
+++ b/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: apple-clang-9, apple-clang-10, apple-clang-11, apple-clang-12.0.0
// <compare>
diff --git a/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp b/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
index b39513a..d7f19ce 100644
--- a/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
+++ b/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
+// UNSUPPORTED: apple-clang-9, apple-clang-10, apple-clang-11, apple-clang-12.0.0
// <compare>