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_iterator_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_iterator_t<std::string>, std::ranges::dangling>); |
22 | static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string&&>, std::ranges::dangling>); |
23 | static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::vector<int> >, std::ranges::dangling>); |
24 | |
25 | static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string&>, std::string::iterator>); |
26 | static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string_view>, std::string_view::iterator>); |
27 | static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::span<int> >, std::span<int>::iterator>); |
28 | |
29 | template <class T> |
30 | constexpr bool has_borrowed_iterator = requires { |
31 | typename std::ranges::borrowed_iterator_t<T>; |
32 | }; |
33 | |
34 | static_assert(!has_borrowed_iterator<int>); |
35 | |