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 explicit sentinel(Parent& parent);
13 
14 #include <cassert>
15 #include <ranges>
16 
17 #include "test_macros.h"
18 #include "../types.h"
19 
test()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   CopyableChild children[4] = {CopyableChild(buffer[0]), CopyableChild(buffer[1]), CopyableChild(buffer[2]), CopyableChild(buffer[3])};
24   CopyableParent parent{children};
25   std::ranges::join_view jv(parent);
26   std::ranges::sentinel_t<decltype(jv)> sent(jv);
27   assert(sent == std::ranges::next(jv.begin(), 16));
28 
29   return true;
30 }
31 
main(int,char **)32 int main(int, char**) {
33   test();
34   static_assert(test());
35 
36   {
37     // Test explicitness.
38     using Parent = std::ranges::join_view<ParentView<ChildView>>;
39     static_assert( std::is_constructible_v<std::ranges::sentinel_t<Parent>, Parent&>);
40     static_assert(!std::is_convertible_v<std::ranges::sentinel_t<Parent>, Parent&>);
41   }
42 
43   return 0;
44 }
45