blob: e97e5659f5c0eaeebb345b6effe2dd94845d90df [file] [log] [blame]
Mark de Weveraf59b2d2020-11-24 18:08:02 +01001// -*- C++ -*-
2//===--------------------------- ranges -----------------------------------===//
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 {
Christopher Di Bella66ce1292021-04-11 05:08:32 +000020 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;
zoecarvere3a4b182021-04-22 09:29:02 -070026
27 inline constexpr unspecified size = unspecified;
zoecarver9ce1b4d2021-04-23 11:23:22 -070028 inline constexpr unspecified ssize = unspecified;
Christopher Di Bella66ce1292021-04-11 05:08:32 +000029 }
30
Mark de Weveraf59b2d2020-11-24 18:08:02 +010031 // [range.range], ranges
32 template<class T>
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000033 concept range = see below;
34
35 template<class T>
Mark de Weveraf59b2d2020-11-24 18:08:02 +010036 inline constexpr bool enable_borrowed_range = false;
Christopher Di Bella66ce1292021-04-11 05:08:32 +000037
38 template<class T>
Louis Dionnee6c2d992021-07-23 16:46:31 -040039 using iterator_t = decltype(ranges::begin(declval<R&>()));
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000040 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>>;
Louis Dionnee6c2d992021-07-23 16:46:31 -040044 template<sized_range R>
45 using range_size_t = decltype(ranges::size(declval<R&>()));
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000046 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
Louis Dionneaab9b222021-07-12 09:55:00 -040053 // [range.sized], sized ranges
Christopher Di Bellae16d01d2021-05-13 19:34:06 +000054 template<class>
55 inline constexpr bool disable_sized_range = false;
56
57 template<class T>
58 concept sized_range = ...;
59
Louis Dionnefa8282c2021-04-28 15:22:11 -040060 // [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
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000069 // [range.refinements], other range refinements
Louis Dionneb53a0ec2021-07-23 15:26:23 -040070 template<class R, class T>
71 concept output_range = see below;
72
Christopher Di Bella8250c632021-04-11 19:04:52 +000073 template<class T>
74 concept input_range = see below;
75
Christopher Di Bella8f1370d2021-04-11 22:11:03 +000076 template<class T>
77 concept forward_range = see below;
78
Christopher Di Bella10a31472021-04-12 01:16:45 +000079 template<class T>
80 concept bidirectional_range = see below;
81
zoecarver3dcd5a12021-06-14 16:08:15 -040082 template<class T>
83 concept random_access_range = see below;
84
85 template<class T>
86 concept contiguous_range = see below;
87
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000088 template <class _Tp>
89 concept common_range = see below;
zoecarver528b66d2021-04-30 15:24:28 -070090
Louis Dionneaab9b222021-07-12 09:55:00 -040091 template<class T>
92 concept viewable_range = see below;
93
zoecarver528b66d2021-04-30 15:24:28 -070094 // [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;
zoecarver671223d2021-05-26 14:25:02 -070098
Christopher Di Bella3cf5ef82021-07-17 01:35:42 +000099 // [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
Christopher Di Bella990b25d2021-07-08 21:01:19 +0000109 // [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
zoecarver671223d2021-05-26 14:25:02 -0700118 // [range.empty], empty view
119 template<class T>
120 requires is_object_v<T>
121 class empty_view;
zoecarverb9f7b7a2021-06-24 11:05:50 -0700122
Louis Dionneaab9b222021-07-12 09:55:00 -0400123 // [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
zoecarverb9f7b7a2021-06-24 11:05:50 -0700138 // [range.drop], drop view
139 template<view V>
140 class drop_view;
141
142 template<class T>
143 inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
zoecarverae914482021-07-09 10:12:16 -0700144
145 // [range.transform], transform view
146 template<input_range V, copy_constructible F>
147 requires view<V> && is_object_v<F> &&
148 regular_invocable<F&, range_reference_t<V>> &&
149 can-reference<invoke_result_t<F&, range_reference_t<V>>>
150 class transform_view;
151
zoecarverbc1ca9a2021-07-09 10:09:31 -0700152 // [range.common], common view
153 template<view V>
154 requires (!common_range<V> && copyable<iterator_t<V>>)
155 class common_view;
156
157 template<class T>
158 inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>;
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100159}
160
161*/
162
163#include <__config>
Christopher Di Bella66ce1292021-04-11 05:08:32 +0000164#include <__ranges/access.h>
zoecarver982808d2021-05-06 15:31:45 -0700165#include <__ranges/all.h>
zoecarverbc1ca9a2021-07-09 10:09:31 -0700166#include <__ranges/common_view.h>
Christopher Di Bella9db3ef22021-04-11 17:40:30 +0000167#include <__ranges/concepts.h>
Christopher Di Bella990b25d2021-07-08 21:01:19 +0000168#include <__ranges/dangling.h>
zoecarver2fbc4d22021-04-23 15:22:18 -0700169#include <__ranges/data.h>
zoecarver545d1d42021-05-06 17:39:53 -0700170#include <__ranges/drop_view.h>
zoecarver85d69332021-04-23 12:34:22 -0700171#include <__ranges/empty.h>
zoecarver671223d2021-05-26 14:25:02 -0700172#include <__ranges/empty_view.h>
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100173#include <__ranges/enable_borrowed_range.h>
Christopher Di Bella46f4bcf2021-06-10 18:40:21 +0000174#include <__ranges/enable_view.h>
zoecarverdd772db2021-05-06 13:19:13 -0700175#include <__ranges/ref_view.h>
zoecarvere3a4b182021-04-22 09:29:02 -0700176#include <__ranges/size.h>
zoecarverbd0551d2021-05-03 14:37:42 -0700177#include <__ranges/subrange.h>
zoecarverae914482021-07-09 10:12:16 -0700178#include <__ranges/transform_view.h>
zoecarver528b66d2021-04-30 15:24:28 -0700179#include <__ranges/view_interface.h>
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100180#include <compare> // Required by the standard.
181#include <initializer_list> // Required by the standard.
182#include <iterator> // Required by the standard.
183#include <type_traits>
184#include <version>
185
186#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
187#pragma GCC system_header
188#endif
189
190_LIBCPP_PUSH_MACROS
191#include <__undef_macros>
192
193_LIBCPP_BEGIN_NAMESPACE_STD
194
195#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
196
197#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
198
199_LIBCPP_END_NAMESPACE_STD
200
201_LIBCPP_POP_MACROS
202
203#endif // _LIBCPP_RANGES