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<class R>
14 //   explicit join_view(R&&) -> join_view<views::all_t<R>>;
15 
16 #include <ranges>
17 #include <utility>
18 
19 struct Child {
20   int *begin() const;
21   int *end() const;
22 };
23 
24 struct View : std::ranges::view_base {
25   Child *begin() const;
26   Child *end() const;
27 };
28 
29 struct Range {
30   Child *begin() const;
31   Child *end() const;
32 };
33 
34 struct BorrowedRange {
35   Child *begin() const;
36   Child *end() const;
37 };
38 template<>
39 inline constexpr bool std::ranges::enable_borrowed_range<BorrowedRange> = true;
40 
41 void testCTAD() {
42     View v;
43     Range r;
44     BorrowedRange br;
45 
46     static_assert(std::same_as<
47         decltype(std::ranges::join_view(v)),
48         std::ranges::join_view<View>
49     >);
50     static_assert(std::same_as<
51         decltype(std::ranges::join_view(std::move(v))),
52         std::ranges::join_view<View>
53     >);
54     static_assert(std::same_as<
55         decltype(std::ranges::join_view(r)),
56         std::ranges::join_view<std::ranges::ref_view<Range>>
57     >);
58     static_assert(std::same_as<
59         decltype(std::ranges::join_view(std::move(r))),
60         std::ranges::join_view<std::ranges::owning_view<Range>>
61     >);
62     static_assert(std::same_as<
63         decltype(std::ranges::join_view(br)),
64         std::ranges::join_view<std::ranges::ref_view<BorrowedRange>>
65     >);
66     static_assert(std::same_as<
67         decltype(std::ranges::join_view(std::move(br))),
68         std::ranges::join_view<std::ranges::owning_view<BorrowedRange>>
69     >);
70 }
71