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