Skip to content

Commit 71a6a1b

Browse files
committed
CI fixes.
1 parent 2dc8392 commit 71a6a1b

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed

libcxx/include/__iterator/bounded_iter.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ struct __bounded_iter {
202202
operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
203203
return __x.__current_ == __y.__current_;
204204
}
205-
#if _LIBCPP_STD_VER <= 17
205+
206206
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
207207
operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
208208
return __x.__current_ != __y.__current_;
@@ -224,14 +224,19 @@ struct __bounded_iter {
224224
return __x.__current_ >= __y.__current_;
225225
}
226226

227-
#else // _LIBCPP_STD_VER <= 17
228-
227+
#if _LIBCPP_STD_VER >= 20
228+
// It is not required that the underlying iterator supports operator<=>.
229+
// Therefore this operator is only conditionally provided, which requires a
230+
// templated function.
231+
template <class _Tp = void>
232+
requires requires(_Iterator const& __i) {
233+
{ __i <=> __i } -> same_as<strong_ordering>;
234+
}
229235
_LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
230236
operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {
231237
return __x.__current_ <=> __y.__current_;
232238
}
233-
234-
#endif // _LIBCPP_STD_VER <= 17
239+
#endif // _LIBCPP_STD_VER >= 20
235240

236241
private:
237242
template <class>

libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//
1212
// Comparison operators
1313

14+
#include <concepts>
1415
#include <__iterator/bounded_iter.h>
1516

1617
#include "test_iterators.h"
@@ -59,6 +60,16 @@ TEST_CONSTEXPR_CXX14 bool tests() {
5960
assert(iter1 >= iter1);
6061
}
6162

63+
#if TEST_STD_VER >= 20
64+
if constexpr (requires(std::__bounded_iter<Iter> const iter) {
65+
{ iter <=> iter } -> std::same_as<std::strong_ordering>;
66+
}) {
67+
// P1614
68+
std::same_as<std::strong_ordering> decltype(auto) r1 = iter1 <=> iter2;
69+
assert(r1 == std::strong_ordering::less);
70+
}
71+
#endif
72+
6273
return true;
6374
}
6475

@@ -69,8 +80,11 @@ int main(int, char**) {
6980
#endif
7081

7182
#if TEST_STD_VER > 17
72-
tests<contiguous_iterator<int*> >();
73-
static_assert(tests<contiguous_iterator<int*> >(), "");
83+
tests<contiguous_iterator<int*>>();
84+
static_assert(tests<contiguous_iterator<int*>>());
85+
86+
tests<three_way_contiguous_iterator<int*>>();
87+
static_assert(tests<three_way_contiguous_iterator<int*>>());
7488
#endif
7589

7690
return 0;

libcxx/test/std/containers/views/views.span/span.iterators/iterator.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
// class iterator
1414

15-
#include <span>
1615
#include <cassert>
16+
#include <concepts>
17+
#include <span>
1718
#include <string>
1819
#include <version> // __cpp_lib_ranges_as_const is not defined in span.
1920

libcxx/test/std/strings/string.view/string.view.iterators/iterators.pass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
// class iterator
1414

15-
#include <string_view>
1615
#include <cassert>
16+
#include <concepts>
1717
#include <iterator>
18+
#include <string_view>
1819

1920
#include "test_macros.h"
2021
#include "make_string.h"

libcxx/test/support/test_iterators.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,8 @@ class contiguous_iterator
389389
friend TEST_CONSTEXPR bool operator> (const contiguous_iterator& x, const contiguous_iterator& y) {return x.it_ > y.it_;}
390390
friend TEST_CONSTEXPR bool operator>=(const contiguous_iterator& x, const contiguous_iterator& y) {return x.it_ >= y.it_;}
391391

392+
// Note no operator<=>, use three_way_contiguous_iterator for testing operator<=>
393+
392394
friend TEST_CONSTEXPR It base(const contiguous_iterator& i) { return i.it_; }
393395

394396
template <class T>

0 commit comments

Comments
 (0)