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