From e94dc78e3bf19cc6504ed1238038c4c3d02dc781 Mon Sep 17 00:00:00 2001 From: Mark de Wever Date: Tue, 23 Jul 2024 18:56:36 +0200 Subject: [PATCH] Addresses review comments. --- libcxx/include/__iterator/bounded_iter.h | 1 + libcxx/include/__iterator/wrap_iter.h | 19 +------------------ libcxx/include/deque | 2 +- .../bounded_iter/comparison.pass.cpp | 10 +++------- .../span.iterators/iterator.pass.cpp | 9 ++++----- 5 files changed, 10 insertions(+), 31 deletions(-) diff --git a/libcxx/include/__iterator/bounded_iter.h b/libcxx/include/__iterator/bounded_iter.h index 78a4e46cd4281b..76647dcaaf02c8 100644 --- a/libcxx/include/__iterator/bounded_iter.h +++ b/libcxx/include/__iterator/bounded_iter.h @@ -211,6 +211,7 @@ struct __bounded_iter { } #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_; diff --git a/libcxx/include/__iterator/wrap_iter.h b/libcxx/include/__iterator/wrap_iter.h index 2598ed4544345c..56183c0ee794d0 100644 --- a/libcxx/include/__iterator/wrap_iter.h +++ b/libcxx/include/__iterator/wrap_iter.h @@ -147,6 +147,7 @@ operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX } #endif +// TODO(mordante) disable these overloads in the LLVM 20 release. template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT { @@ -184,23 +185,6 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX } #if _LIBCPP_STD_VER >= 20 - -template -_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering -operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) noexcept { - if constexpr (three_way_comparable<_Iter1, strong_ordering>) { - return __x.base() <=> __y.base(); - } else { - if (__x.base() < __y.base()) - return strong_ordering::less; - - if (__x.base() == __y.base()) - return strong_ordering::equal; - - return strong_ordering::greater; - } -} - template _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept { @@ -216,7 +200,6 @@ operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noex return strong_ordering::greater; } } - #endif // _LIBCPP_STD_VER >= 20 template diff --git a/libcxx/include/deque b/libcxx/include/deque index a5b3ee298fb51d..e73135a8647b98 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -382,6 +382,7 @@ public: } #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 +400,6 @@ public: } #if _LIBCPP_STD_VER >= 20 - // template _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; diff --git a/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp b/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp index 071a67fce93328..cef2157469c8f0 100644 --- a/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp +++ b/libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp @@ -61,13 +61,9 @@ TEST_CONSTEXPR_CXX14 bool tests() { } #if TEST_STD_VER >= 20 - if constexpr (requires(std::__bounded_iter const iter) { - { iter <=> iter } -> std::same_as; - }) { - // P1614 - std::same_as decltype(auto) r1 = iter1 <=> iter2; - assert(r1 == std::strong_ordering::less); - } + // P1614 + std::same_as decltype(auto) r1 = iter1 <=> iter2; + assert(r1 == std::strong_ordering::less); #endif return true; diff --git a/libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp b/libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp index b097e4dc994a7c..13a7628e6043d9 100644 --- a/libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp +++ b/libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp @@ -22,14 +22,13 @@ #include "test_macros.h" template -TEST_CONSTEXPR void test_type() { -# - +constexpr void test_type() { using C = std::span; typename C::iterator ii1{}, ii2{}; typename C::iterator ii4 = ii1; // TODO Test against C++23 after implementing - // P2278R4 cbegin should always return a constant iterator + // P2278R4 cbegin should always return a constant iterator + // The means adjusting the #ifdef to guard against C++23. #ifdef __cpp_lib_ranges_as_const typename C::const_iterator cii{}; #endif @@ -77,7 +76,7 @@ TEST_CONSTEXPR void test_type() { #endif } -TEST_CONSTEXPR bool test() { +constexpr bool test() { test_type(); test_type(); test_type();