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 // template<bool OtherConst> 13 // requires sentinel_for<sentinel_t<Base>, iterator_t<maybe-const<OtherConst, V>>> 14 // friend constexpr bool operator==(const iterator<OtherConst>& x, const sentinel& y); 15 16 #include <cassert> 17 #include <ranges> 18 19 #include "test_macros.h" 20 #include "../types.h" 21 22 constexpr bool test() { 23 int buffer[4][4] = {{1111, 2222, 3333, 4444}, {555, 666, 777, 888}, {99, 1010, 1111, 1212}, {13, 14, 15, 16}}; 24 25 { 26 ChildView children[4] = {ChildView(buffer[0]), ChildView(buffer[1]), ChildView(buffer[2]), ChildView(buffer[3])}; 27 auto jv = std::ranges::join_view(ParentView(children)); 28 assert(jv.end() == std::ranges::next(jv.begin(), 16)); 29 } 30 { 31 CopyableChild children[4] = {CopyableChild(buffer[0]), CopyableChild(buffer[1]), CopyableChild(buffer[2]), CopyableChild(buffer[3])}; 32 const auto jv = std::ranges::join_view(ParentView(children)); 33 assert(jv.end() == std::ranges::next(jv.begin(), 16)); 34 } 35 { 36 CopyableChild children[4] = {CopyableChild(buffer[0]), CopyableChild(buffer[1]), CopyableChild(buffer[2]), CopyableChild(buffer[3])}; 37 const std::ranges::join_view jvc(CopyableParent{children}); 38 std::ranges::join_view jv(CopyableParent{children}); 39 assert(jvc.end() == std::ranges::next(jv.begin(), 16)); 40 assert( jv.end() == std::ranges::next(jvc.begin(), 16)); 41 } 42 43 return true; 44 } 45 46 int main(int, char**) { 47 test(); 48 static_assert(test()); 49 50 return 0; 51 } 52