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