From 20506fb1f361e41012506c6c252fd690541fc708 Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Mon, 12 Apr 2021 20:55:05 +0000 Subject: [PATCH] [libcxx] removes operator!= and globally guards against no spaceship operator * `operator!=` isn't in the spec * `` 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 --- libcxx/include/compare | 64 +--------------------- .../cmp/cmp.categories.pre/zero_type.verify.cpp | 1 + .../cmp/cmp.partialord/partialord.pass.cpp | 1 + .../cmp/cmp.strongord/strongord.pass.cpp | 1 + .../cmp/cmp.weakord/weakord.pass.cpp | 1 + 5 files changed, 6 insertions(+), 62 deletions(-) diff --git a/libcxx/include/compare b/libcxx/include/compare index ff3469d..0a2b3d0 100644 --- a/libcxx/include/compare +++ b/libcxx/include/compare @@ -129,8 +129,7 @@ namespace std { _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 @@ public: // 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 @@ constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { } _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 @@ constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { } _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 @@ _LIBCPP_INLINE_VISIBILITY 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 @@ public: // 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 @@ 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; -} -_LIBCPP_INLINE_VISIBILITY constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { return __v.__value_ < 0; } @@ -347,14 +317,6 @@ constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { 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 @@ constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { 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 @@ _LIBCPP_INLINE_VISIBILITY 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 @@ public: // 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 @@ 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; -} -_LIBCPP_INLINE_VISIBILITY constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { return __v.__value_ < 0; } @@ -464,14 +414,6 @@ constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { 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 @@ constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { 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 @@ _LIBCPP_INLINE_VISIBILITY 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 constexpr strong_ordering strong_order(const _Tp& __lhs, con template constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs); template 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/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 index fc21c03..c0fe4cb 100644 --- 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 @@ -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 // 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 index c473073..0b5169f 100644 --- a/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp +++ b/libcxx/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 // 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 index 40ffb35..e8b9733 100644 --- a/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp +++ b/libcxx/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 // 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 index b39513a..d7f19ce 100644 --- a/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp +++ b/libcxx/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 // -- 2.7.4