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 // template<class T> 15 // concept input_iterator; 16 17 // std::ranges::forward_range 18 19 #include <ranges> 20 21 #include <iterator> 22 23 struct range { 24 int* begin(); 25 int* end(); 26 }; 27 28 template<std::ranges::range R> 29 requires std::input_iterator<std::ranges::iterator_t<R>> 30 constexpr bool check_input_range_subsumption() { 31 return false; 32 } 33 34 template<std::ranges::input_range> 35 requires true 36 constexpr bool check_input_range_subsumption() { 37 return true; 38 } 39 40 static_assert(check_input_range_subsumption<range>()); 41 42 template<std::ranges::input_range R> 43 requires std::forward_iterator<std::ranges::iterator_t<R>> 44 constexpr bool check_forward_range_subsumption() { 45 return false; 46 } 47 48 template<std::ranges::forward_range> 49 requires true 50 constexpr bool check_forward_range_subsumption() { 51 return true; 52 } 53 54 static_assert(check_forward_range_subsumption<range>()); 55 56 template<std::ranges::forward_range R> 57 requires std::bidirectional_iterator<std::ranges::iterator_t<R>> 58 constexpr bool check_bidirectional_range_subsumption() { 59 return false; 60 } 61 62 template<std::ranges::bidirectional_range> 63 requires true 64 constexpr bool check_bidirectional_range_subsumption() { 65 return true; 66 } 67 68 static_assert(check_bidirectional_range_subsumption<range>()); 69 70 template<std::ranges::bidirectional_range R> 71 requires std::random_access_iterator<std::ranges::iterator_t<R>> 72 constexpr bool check_random_access_range_subsumption() { 73 return false; 74 } 75 76 template<std::ranges::random_access_range> 77 requires true 78 constexpr bool check_random_access_range_subsumption() { 79 return true; 80 } 81 82 static_assert(check_random_access_range_subsumption<range>()); 83 84 template<std::ranges::random_access_range R> 85 requires std::random_access_iterator<std::ranges::iterator_t<R>> 86 constexpr bool check_contiguous_range_subsumption() { 87 return false; 88 } 89 90 template<std::ranges::contiguous_range> 91 requires true 92 constexpr bool check_contiguous_range_subsumption() { 93 return true; 94 } 95 96 static_assert(check_contiguous_range_subsumption<range>()); 97