[libcxx-commits] [libcxx] 39b6900 - [libc++][spaceship] Removes unneeded relational operators. (#100441)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 30 10:06:18 PDT 2024
Author: Mark de Wever
Date: 2024-07-30T19:06:15+02:00
New Revision: 39b6900852e7a1187bd742ba5c1387ca1be58e2c
URL: https://github.com/llvm/llvm-project/commit/39b6900852e7a1187bd742ba5c1387ca1be58e2c
DIFF: https://github.com/llvm/llvm-project/commit/39b6900852e7a1187bd742ba5c1387ca1be58e2c.diff
LOG: [libc++][spaceship] Removes unneeded relational operators. (#100441)
This is a followup of https://github.com/llvm/llvm-project/pull/99343.
Since that patch was quite late in the LLVM-19 release cycle some of the
unneeded relational operator were not removed in C++20.
This removes them and gives the change a bit more "baking" time, just in
case there are issues with this change in user code. This change is
intended to be an NFC.
Added:
Modified:
libcxx/include/__iterator/bounded_iter.h
libcxx/include/__iterator/wrap_iter.h
libcxx/include/deque
Removed:
################################################################################
diff --git a/libcxx/include/__iterator/bounded_iter.h b/libcxx/include/__iterator/bounded_iter.h
index 8a81c9ffbfc3f..5a86bd98e7194 100644
--- a/libcxx/include/__iterator/bounded_iter.h
+++ b/libcxx/include/__iterator/bounded_iter.h
@@ -209,9 +209,7 @@ struct __bounded_iter {
operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
return __x.__current_ != __y.__current_;
}
-#endif
- // TODO(mordante) disable these overloads in the LLVM 20 release.
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
return __x.__current_ < __y.__current_;
@@ -229,7 +227,7 @@ struct __bounded_iter {
return __x.__current_ >= __y.__current_;
}
-#if _LIBCPP_STD_VER >= 20
+#else
_LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {
if constexpr (three_way_comparable<_Iterator, strong_ordering>) {
diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h
index 56183c0ee794d..34f8d5f1663b2 100644
--- a/libcxx/include/__iterator/wrap_iter.h
+++ b/libcxx/include/__iterator/wrap_iter.h
@@ -145,9 +145,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
return !(__x == __y);
}
-#endif
-
-// TODO(mordante) disable these overloads in the LLVM 20 release.
template <class _Iter1>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
@@ -184,7 +181,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
return !(__y < __x);
}
-#if _LIBCPP_STD_VER >= 20
+#else
template <class _Iter1, class _Iter2>
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
diff --git a/libcxx/include/deque b/libcxx/include/deque
index e73135a8647b9..759de5d3a030a 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -380,9 +380,6 @@ public:
_LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) {
return !(__x == __y);
}
-#endif
-
- // TODO(mordante) disable these overloads in the LLVM 20 release.
_LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) {
return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);
}
@@ -399,7 +396,8 @@ public:
return !(__x < __y);
}
-#if _LIBCPP_STD_VER >= 20
+#else
+
_LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) {
if (__x.__m_iter_ < __y.__m_iter_)
return strong_ordering::less;
More information about the libcxx-commits
mailing list