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

source code of libcxx/test/std/ranges/range.req/range.refinements/subsumption.compile.pass.cpp