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