1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 
11 // ranges::next(it)
12 
13 #include <iterator>
14 
15 #include <cassert>
16 #include <concepts>
17 #include <utility>
18 
19 #include "test_iterators.h"
20 
21 template <class It>
check(int * first,int * expected)22 constexpr void check(int* first, int* expected) {
23   It it(first);
24   std::same_as<It> auto result = std::ranges::next(std::move(it));
25   assert(base(result) == expected);
26 }
27 
test()28 constexpr bool test() {
29   int range[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
30 
31   for (int n = 0; n != 9; ++n) {
32     check<cpp17_input_iterator<int*>>(  range+n, range+n+1);
33     check<cpp20_input_iterator<int*>>(  range+n, range+n+1);
34     check<forward_iterator<int*>>(      range+n, range+n+1);
35     check<bidirectional_iterator<int*>>(range+n, range+n+1);
36     check<random_access_iterator<int*>>(range+n, range+n+1);
37     check<contiguous_iterator<int*>>(   range+n, range+n+1);
38     check<cpp17_output_iterator<int*>>( range+n, range+n+1);
39     check<int*>(                        range+n, range+n+1);
40   }
41 
42   return true;
43 }
44 
main(int,char **)45 int main(int, char**) {
46   test();
47   static_assert(test());
48   return 0;
49 }
50