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 join_view(V base);
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] = {{1111, 2222, 3333, 4444}, {555, 666, 777, 888}, {99, 1010, 1111, 1212}, {13, 14, 15, 16}};
22
23 {
24 ChildView children[4] = {ChildView(buffer[0]), ChildView(buffer[1]), ChildView(buffer[2]), ChildView(buffer[3])};
25 auto jv = std::ranges::join_view(ParentView{children});
26 assert(std::move(jv).base().ptr_ == children);
27 }
28
29 {
30 std::ranges::join_view jv(buffer);
31 assert(jv.base().base() == buffer + 0);
32 }
33
34 {
35 // Test explicitness.
36 static_assert( std::is_constructible_v<std::ranges::join_view<ParentView<ChildView>>, ParentView<ChildView>>);
37 static_assert(!std::is_convertible_v<std::ranges::join_view<ParentView<ChildView>>, ParentView<ChildView>>);
38 }
39
40 return true;
41 }
42
main(int,char **)43 int main(int, char**) {
44 test();
45 static_assert(test());
46
47 return 0;
48 }
49