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