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 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
12 
13 // constexpr decltype(auto) operator*() const;
14 
15 #include <cassert>
16 #include <ranges>
17 
18 #include "test_macros.h"
19 #include "../types.h"
20 
21 constexpr bool test() {
22   int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
23 
24   {
25     std::ranges::join_view jv(buffer);
26     auto iter = jv.begin();
27     for (int i = 1; i < 17; ++i) {
28       assert(*iter++ == i);
29     }
30   }
31   {
32     std::ranges::join_view jv(buffer);
33     auto iter = std::next(jv.begin(), 15);
34     assert(*iter++ == 16);
35     assert(iter == jv.end());
36   }
37   {
38     ChildView children[4] = {ChildView(buffer[0]), ChildView(buffer[1]), ChildView(buffer[2]), ChildView(buffer[3])};
39     auto jv = std::ranges::join_view(ParentView(children));
40     auto iter = jv.begin();
41     for (int i = 1; i < 17; ++i) {
42       assert(*iter == i);
43       ++iter;
44     }
45   }
46 
47   return true;
48 }
49 
50 int main(int, char**) {
51   test();
52   static_assert(test());
53 
54   return 0;
55 }
56