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