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

source code of libcxx/test/std/ranges/range.utility/range.dangling/borrowed_iterator.compile.pass.cpp