Skip to content

Commit

Permalink
Addresses review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mordante committed Jul 24, 2024
1 parent ecd6887 commit e94dc78
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 31 deletions.
1 change: 1 addition & 0 deletions libcxx/include/__iterator/bounded_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
19 changes: 1 addition & 18 deletions libcxx/include/__iterator/wrap_iter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class _Iter1>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
Expand Down Expand Up @@ -184,23 +185,6 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
}

#if _LIBCPP_STD_VER >= 20

template <class _Iter1>
_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 <class _Iter1, class _Iter2>
_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
Expand All @@ -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 <class _Iter1, class _Iter2>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/deque
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
}
Expand All @@ -399,7 +400,6 @@ public:
}

#if _LIBCPP_STD_VER >= 20
// template <class _Tp = void>
_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;
Expand Down
10 changes: 3 additions & 7 deletions libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,9 @@ TEST_CONSTEXPR_CXX14 bool tests() {
}

#if TEST_STD_VER >= 20
if constexpr (requires(std::__bounded_iter<Iter> const iter) {
{ iter <=> iter } -> std::same_as<std::strong_ordering>;
}) {
// P1614
std::same_as<std::strong_ordering> decltype(auto) r1 = iter1 <=> iter2;
assert(r1 == std::strong_ordering::less);
}
// P1614
std::same_as<std::strong_ordering> decltype(auto) r1 = iter1 <=> iter2;
assert(r1 == std::strong_ordering::less);
#endif

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
#include "test_macros.h"

template <class T>
TEST_CONSTEXPR void test_type() {
#

constexpr void test_type() {
using C = std::span<T>;
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
Expand Down Expand Up @@ -77,7 +76,7 @@ TEST_CONSTEXPR void test_type() {
#endif
}

TEST_CONSTEXPR bool test() {
constexpr bool test() {
test_type<char>();
test_type<int>();
test_type<std::string>();
Expand Down

0 comments on commit e94dc78

Please sign in to comment.