Skip to content

Commit e2aa538

Browse files
committed
[libc++][ranges] refactor 'ranges.shift_left.pass.cpp'
1 parent c2fc0dc commit e2aa538

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

libcxx/test/std/algorithms/alg.modifying.operations/alg.shift/ranges.shift_left.pass.cpp

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,24 @@
1919

2020
#include <algorithm>
2121
#include <array>
22+
#include <cassert>
2223
#include <ranges>
2324
#include <iterator>
2425

2526
#include "almost_satisfies_types.h"
2627
#include "test_iterators.h"
2728
#include "MoveOnly.h"
2829

29-
template <class Iter, class Sent = Iter, class Count = std::size_t>
30-
concept HasShiftLeftIt = requires(Iter iter, Sent sent, Count n) { std::ranges::shift_left(iter, sent, n); };
30+
template <class Iter, class Sent = Iter>
31+
concept HasShiftLeftIt = requires(Iter iter, Sent sent, std::size_t n) { std::ranges::shift_left(iter, sent, n); };
3132

3233
static_assert(HasShiftLeftIt<int*>);
3334
static_assert(!HasShiftLeftIt<ForwardIteratorNotDerivedFrom>);
3435
static_assert(!HasShiftLeftIt<PermutableNotForwardIterator>);
3536
static_assert(!HasShiftLeftIt<PermutableNotSwappable>);
3637

37-
template <class Range, class Count = std::size_t>
38-
concept HasShiftLeftR = requires(Range range, Count n) { std::ranges::shift_left(range, n); };
38+
template <class Range>
39+
concept HasShiftLeftR = requires(Range range, std::size_t n) { std::ranges::shift_left(range, n); };
3940

4041
static_assert(HasShiftLeftR<UncheckedRange<int*>>);
4142
static_assert(!HasShiftLeftR<ForwardRangeNotDerivedFrom>);
@@ -170,25 +171,17 @@ constexpr void test_iter_sent() {
170171
}
171172
}
172173

173-
template <class Iter>
174-
constexpr void test_iter() {
175-
test_iter_sent<Iter, Iter>();
176-
test_iter_sent<Iter, sentinel_wrapper<Iter>>();
177-
test_iter_sent<Iter, sized_sentinel<Iter>>();
178-
}
179-
180174
constexpr bool test() {
181-
test_iter<forward_iterator<int*>>();
182-
test_iter<bidirectional_iterator<int*>>();
183-
test_iter<random_access_iterator<int*>>();
184-
test_iter<contiguous_iterator<int*>>();
185-
test_iter<int*>();
175+
types::for_each(types::forward_iterator_list<int*>{}, []<class Iter> {
176+
test_iter_sent<Iter, Iter>();
177+
test_iter_sent<Iter, sentinel_wrapper<Iter>>();
178+
test_iter_sent<Iter, sized_sentinel<Iter>>();
179+
});
186180
return true;
187181
}
188182

189183
int main(int, char**) {
190184
test();
191185
static_assert(test());
192-
193186
return 0;
194187
}

0 commit comments

Comments
 (0)