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