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