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-has-no-incomplete-ranges
11 
12 // constexpr InnerIter operator->() const
13 //   requires has-arrow<InnerIter> && copyable<InnerIter>;
14 
15 #include <cassert>
16 #include <ranges>
17 
18 #include "test_macros.h"
19 #include "../types.h"
20 
21 constexpr bool test() {
22   Box buffer[4][4] = {{{1111}, {2222}, {3333}, {4444}}, {{555}, {666}, {777}, {888}}, {{99}, {1010}, {1111}, {1212}}, {{13}, {14}, {15}, {16}}};
23 
24   {
25     // Copyable input iterator with arrow.
26     ValueView<Box> children[4] = {ValueView(buffer[0]), ValueView(buffer[1]), ValueView(buffer[2]), ValueView(buffer[3])};
27     std::ranges::join_view jv(ValueView<ValueView<Box>>{children});
28     assert(jv.begin()->x == 1111);
29   }
30 
31   {
32     std::ranges::join_view jv(buffer);
33     assert(jv.begin()->x == 1111);
34   }
35 
36   {
37     const std::ranges::join_view jv(buffer);
38     assert(jv.begin()->x == 1111);
39   }
40 
41   return true;
42 }
43 
44 int main(int, char**) {
45   test();
46   static_assert(test());
47 
48   return 0;
49 }
50