1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5// See https://llvm.org/LICENSE.txt for license information. 6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_RANGES 11#define _LIBCPP_RANGES 12 13/* 14 15#include <compare> // see [compare.syn] 16#include <initializer_list> // see [initializer.list.syn] 17#include <iterator> // see [iterator.synopsis] 18 19namespace std::ranges { 20 inline namespace unspecified { 21 // [range.access], range access 22 inline constexpr unspecified begin = unspecified; 23 inline constexpr unspecified end = unspecified; 24 inline constexpr unspecified cbegin = unspecified; 25 inline constexpr unspecified cend = unspecified; 26 27 inline constexpr unspecified size = unspecified; 28 inline constexpr unspecified ssize = unspecified; 29 } 30 31 // [range.range], ranges 32 template<class T> 33 concept range = see below; 34 35 template<class T> 36 inline constexpr bool enable_borrowed_range = false; 37 38 template<class T> 39 using iterator_t = decltype(ranges::begin(declval<T&>())); 40 template<range R> 41 using sentinel_t = decltype(ranges::end(declval<R&>())); 42 template<range R> 43 using range_difference_t = iter_difference_t<iterator_t<R>>; 44 template<sized_range R> 45 using range_size_t = decltype(ranges::size(declval<R&>())); 46 template<range R> 47 using range_value_t = iter_value_t<iterator_t<R>>; 48 template<range R> 49 using range_reference_t = iter_reference_t<iterator_t<R>>; 50 template<range R> 51 using range_rvalue_reference_t = iter_rvalue_reference_t<iterator_t<R>>; 52 53 // [range.sized], sized ranges 54 template<class> 55 inline constexpr bool disable_sized_range = false; 56 57 template<class T> 58 concept sized_range = ...; 59 60 // [range.view], views 61 template<class T> 62 inline constexpr bool enable_view = ...; 63 64 struct view_base { }; 65 66 template<class T> 67 concept view = ...; 68 69 // [range.refinements], other range refinements 70 template<class R, class T> 71 concept output_range = see below; 72 73 template<class T> 74 concept input_range = see below; 75 76 template<class T> 77 concept forward_range = see below; 78 79 template<class T> 80 concept bidirectional_range = see below; 81 82 template<class T> 83 concept random_access_range = see below; 84 85 template<class T> 86 concept contiguous_range = see below; 87 88 template <class _Tp> 89 concept common_range = see below; 90 91 template<class T> 92 concept viewable_range = see below; 93 94 // [view.interface], class template view_interface 95 template<class D> 96 requires is_class_v<D> && same_as<D, remove_cv_t<D>> 97 class view_interface; 98 99 // [range.subrange], sub-ranges 100 enum class subrange_kind : bool { unsized, sized }; 101 102 template<input_or_output_iterator I, sentinel_for<I> S = I, subrange_kind K = see below> 103 requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>) 104 class subrange; 105 106 template<class I, class S, subrange_kind K> 107 inline constexpr bool enable_borrowed_range<subrange<I, S, K>> = true; 108 109 // [range.dangling], dangling iterator handling 110 struct dangling; 111 112 template<range R> 113 using borrowed_iterator_t = see below; 114 115 template<range R> 116 using borrowed_subrange_t = see below; 117 118 // [range.empty], empty view 119 template<class T> 120 requires is_object_v<T> 121 class empty_view; 122 123 // [range.all], all view 124 namespace views { 125 inline constexpr unspecified all = unspecified; 126 127 template<viewable_range R> 128 using all_t = decltype(all(declval<R>())); 129 } 130 131 template<range R> 132 requires is_object_v<R> 133 class ref_view; 134 135 template<class T> 136 inline constexpr bool enable_borrowed_range<ref_view<T>> = true; 137 138 template<range R> 139 requires see below 140 class owning_view; 141 142 template<class T> 143 inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>; 144 145 // [range.drop], drop view 146 template<view V> 147 class drop_view; 148 149 template<class T> 150 inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>; 151 152 // [range.transform], transform view 153 template<input_range V, copy_constructible F> 154 requires view<V> && is_object_v<F> && 155 regular_invocable<F&, range_reference_t<V>> && 156 can-reference<invoke_result_t<F&, range_reference_t<V>>> 157 class transform_view; 158 159 // [range.counted], counted view 160 namespace views { inline constexpr unspecified counted = unspecified; } 161 162 // [range.common], common view 163 template<view V> 164 requires (!common_range<V> && copyable<iterator_t<V>>) 165 class common_view; 166 167 // [range.reverse], reverse view 168 template<view V> 169 requires bidirectional_range<V> 170 class reverse_view; 171 172 template<class T> 173 inline constexpr bool enable_borrowed_range<reverse_view<T>> = enable_borrowed_range<T>; 174 175 template<class T> 176 inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>; 177 178 // [range.take], take view 179 template<view> class take_view; 180 181 template<class T> 182 inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>; 183 184 template<copy_constructible T> 185 requires is_object_v<T> 186 class single_view; 187 188 template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t> 189 requires weakly-equality-comparable-with<W, Bound> && copyable<W> 190 class iota_view; 191 192 template<class W, class Bound> 193 inline constexpr bool enable_borrowed_range<iota_view<W, Bound>> = true; 194 195 // [range.join], join view 196 template<input_range V> 197 requires view<V> && input_range<range_reference_t<V>> 198 class join_view; 199} 200 201*/ 202 203#include <__config> 204#include <__ranges/access.h> 205#include <__ranges/all.h> 206#include <__ranges/common_view.h> 207#include <__ranges/concepts.h> 208#include <__ranges/counted.h> 209#include <__ranges/dangling.h> 210#include <__ranges/data.h> 211#include <__ranges/drop_view.h> 212#include <__ranges/empty.h> 213#include <__ranges/empty_view.h> 214#include <__ranges/enable_borrowed_range.h> 215#include <__ranges/enable_view.h> 216#include <__ranges/iota_view.h> 217#include <__ranges/join_view.h> 218#include <__ranges/ref_view.h> 219#include <__ranges/reverse_view.h> 220#include <__ranges/single_view.h> 221#include <__ranges/size.h> 222#include <__ranges/subrange.h> 223#include <__ranges/take_view.h> 224#include <__ranges/transform_view.h> 225#include <__ranges/view_interface.h> 226#include <__ranges/views.h> 227#include <compare> // Required by the standard. 228#include <initializer_list> // Required by the standard. 229#include <iterator> // Required by the standard. 230#include <type_traits> 231#include <version> 232 233#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 234#pragma GCC system_header 235#endif 236 237#endif // _LIBCPP_RANGES 238