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 | // std::ranges::borrowed_subrange_t; |
12 | |
13 | #include <ranges> |
14 | |
15 | #include <concepts> |
16 | #include <span> |
17 | #include <string> |
18 | #include <string_view> |
19 | #include <vector> |
20 | |
21 | static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string>, std::ranges::dangling>); |
22 | static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string&&>, std::ranges::dangling>); |
23 | static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::vector<int> >, std::ranges::dangling>); |
24 | |
25 | static_assert( |
26 | std::same_as<std::ranges::borrowed_subrange_t<std::string&>, std::ranges::subrange<std::string::iterator> >); |
27 | |
28 | static_assert( |
29 | std::same_as<std::ranges::borrowed_subrange_t<std::span<int> >, std::ranges::subrange<std::span<int>::iterator> >); |
30 | |
31 | static_assert(std::same_as<std::ranges::borrowed_subrange_t<std::string_view>, |
32 | std::ranges::subrange<std::string_view::iterator> >); |
33 | |
34 | template <class T> |
35 | constexpr bool has_type = requires { |
36 | typename std::ranges::borrowed_subrange_t<T>; |
37 | }; |
38 | |
39 | static_assert(!has_type<int>); |
40 | |
41 | struct S {}; |
42 | static_assert(!has_type<S>); |
43 | |