2626
2727#include " almost_satisfies_types.h"
2828#include " test_iterators.h"
29+ #include " type_algorithms.h"
2930
3031template <class Iter , class Out = int *, class Sent = sentinel_wrapper<Iter>>
31- concept HasRotateCopyIt = requires (Iter first, Sent last, Out out) { std::ranges::rotate_copy (first, first, last, out); };
32+ concept HasRotateCopyIt =
33+ requires (Iter first, Sent last, Out out) { std::ranges::rotate_copy (first, first, last, out); };
3234
3335template <class Range , class Out = int *>
3436concept HasRotateCopyR = requires (Range range, Out out) { std::ranges::rotate_copy (range, nullptr , out); };
@@ -54,11 +56,8 @@ template <class Iter, class OutIter, class Sent, int N>
5456constexpr void test (std::array<int , N> value, std::size_t middle, std::array<int , N> expected) {
5557 {
5658 std::array<int , N> out;
57- std::same_as<std::ranges::in_out_result<Iter, OutIter>> decltype (auto ) ret =
58- std::ranges::rotate_copy (Iter (value.data ()),
59- Iter (value.data () + middle),
60- Sent (Iter (value.data () + value.size ())),
61- OutIter (out.data ()));
59+ std::same_as<std::ranges::in_out_result<Iter, OutIter>> decltype (auto ) ret = std::ranges::rotate_copy (
60+ Iter (value.data ()), Iter (value.data () + middle), Sent (Iter (value.data () + value.size ())), OutIter (out.data ()));
6261 assert (base (ret.in ) == value.data () + value.size ());
6362 assert (base (ret.out ) == out.data () + out.size ());
6463 assert (out == expected);
@@ -74,7 +73,7 @@ constexpr void test(std::array<int, N> value, std::size_t middle, std::array<int
7473 }
7574}
7675
77- template <class Iter , class OutIter , class Sent >
76+ template <class Iter , class OutIter , class Sent = Iter >
7877constexpr void test_iterators () {
7978 // simple test
8079 test<Iter, OutIter, Sent, 4 >({1 , 2 , 3 , 4 }, 2 , {3 , 4 , 1 , 2 });
@@ -101,41 +100,33 @@ constexpr void test_iterators() {
101100 test<Iter, OutIter, Sent, 7 >({1 , 2 , 3 , 4 , 5 , 6 , 7 }, 7 , {1 , 2 , 3 , 4 , 5 , 6 , 7 });
102101}
103102
104- template <class Iter , class Sent = Iter>
105- constexpr void test_out_iterators () {
106- test_iterators<Iter, cpp20_output_iterator<int *>, Sent>();
107- test_iterators<Iter, forward_iterator<int *>, Sent>();
108- test_iterators<Iter, bidirectional_iterator<int *>, Sent>();
109- test_iterators<Iter, random_access_iterator<int *>, Sent>();
110- test_iterators<Iter, contiguous_iterator<int *>, Sent>();
111- test_iterators<Iter, int *, Sent>();
112- }
113-
114103constexpr bool test () {
115- test_out_iterators<forward_iterator<int *>>();
116- test_out_iterators<bidirectional_iterator<int *>>();
117- test_out_iterators<random_access_iterator<int *>>();
118- test_out_iterators<contiguous_iterator<int *>>();
119- test_out_iterators<int *>();
120- test_out_iterators<const int *>();
104+ types::for_each (types::forward_iterator_list<int *>(), []<class Iter >() {
105+ types::for_each (types::cpp20_output_iterator_list<int *>(), []<class OutIter >() {
106+ test_iterators<Iter, OutIter>();
107+ });
108+ });
121109
122110 {
123111 struct AssignmentCounter {
124112 int * counter;
125113
126114 constexpr AssignmentCounter (int * counter_) : counter(counter_) {}
127- constexpr AssignmentCounter& operator =(const AssignmentCounter&) { ++*counter; return *this ; }
115+ constexpr AssignmentCounter& operator =(const AssignmentCounter&) {
116+ ++*counter;
117+ return *this ;
118+ }
128119 };
129120
130121 {
131- int c = 0 ;
122+ int c = 0 ;
132123 AssignmentCounter a[] = {&c, &c, &c, &c};
133124 AssignmentCounter b[] = {&c, &c, &c, &c};
134125 std::ranges::rotate_copy (a, a + 2 , a + 4 , b);
135126 assert (c == 4 );
136127 }
137128 {
138- int c = 0 ;
129+ int c = 0 ;
139130 AssignmentCounter a[] = {&c, &c, &c, &c};
140131 AssignmentCounter b[] = {&c, &c, &c, &c};
141132 std::ranges::rotate_copy (a, a + 2 , b);
0 commit comments