174fd3cb8SChristopher Di Bella //===----------------------------------------------------------------------===//
274fd3cb8SChristopher Di Bella //
374fd3cb8SChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
474fd3cb8SChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
574fd3cb8SChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
674fd3cb8SChristopher Di Bella //
774fd3cb8SChristopher Di Bella //===----------------------------------------------------------------------===//
874fd3cb8SChristopher Di Bella 
974fd3cb8SChristopher Di Bella // UNSUPPORTED: c++03, c++11, c++14, c++17
10*71909de3SMark de Wever // UNSUPPORTED: libcpp-has-no-incomplete-ranges
1174fd3cb8SChristopher Di Bella 
1274fd3cb8SChristopher Di Bella // std::ranges::borrowed_iterator_t;
1374fd3cb8SChristopher Di Bella 
1474fd3cb8SChristopher Di Bella #include <ranges>
1574fd3cb8SChristopher Di Bella 
1674fd3cb8SChristopher Di Bella #include <concepts>
1774fd3cb8SChristopher Di Bella #include <span>
1874fd3cb8SChristopher Di Bella #include <string>
1974fd3cb8SChristopher Di Bella #include <string_view>
2074fd3cb8SChristopher Di Bella #include <vector>
2174fd3cb8SChristopher Di Bella 
2274fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string>, std::ranges::dangling>);
2374fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string&&>, std::ranges::dangling>);
2474fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::vector<int> >, std::ranges::dangling>);
2574fd3cb8SChristopher Di Bella 
2674fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string&>, std::string::iterator>);
2774fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::string_view>, std::string_view::iterator>);
2874fd3cb8SChristopher Di Bella static_assert(std::same_as<std::ranges::borrowed_iterator_t<std::span<int> >, std::span<int>::iterator>);
2974fd3cb8SChristopher Di Bella 
3074fd3cb8SChristopher Di Bella template <class T>
3174fd3cb8SChristopher Di Bella constexpr bool has_borrowed_iterator = requires {
3274fd3cb8SChristopher Di Bella   typename std::ranges::borrowed_iterator_t<T>;
3374fd3cb8SChristopher Di Bella };
3474fd3cb8SChristopher Di Bella 
3574fd3cb8SChristopher Di Bella static_assert(!has_borrowed_iterator<int>);
36