blob: 367ad60226d4eaca42a02e7d8a744fdcf1076424 [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>
39 using iterator_t = decltype(ranges::begin(declval<T&>()));
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000040 template<class T>
41 using iterator_t = decltype(ranges::begin(declval<T&>()));
42 template<range R>
43 using sentinel_t = decltype(ranges::end(declval<R&>()));
44 template<range R>
45 using range_difference_t = iter_difference_t<iterator_t<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
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
Christopher Di Bella8250c632021-04-11 19:04:52 +000070 template<class T>
71 concept input_range = see below;
72
Christopher Di Bella8f1370d2021-04-11 22:11:03 +000073 template<class T>
74 concept forward_range = see below;
75
Christopher Di Bella10a31472021-04-12 01:16:45 +000076 template<class T>
77 concept bidirectional_range = see below;
78
zoecarver3dcd5a12021-06-14 16:08:15 -040079 template<class T>
80 concept random_access_range = see below;
81
82 template<class T>
83 concept contiguous_range = see below;
84
Christopher Di Bella9db3ef22021-04-11 17:40:30 +000085 template <class _Tp>
86 concept common_range = see below;
zoecarver528b66d2021-04-30 15:24:28 -070087
Louis Dionneaab9b222021-07-12 09:55:00 -040088 template<class T>
89 concept viewable_range = see below;
90
zoecarver528b66d2021-04-30 15:24:28 -070091 // [view.interface], class template view_interface
92 template<class D>
93 requires is_class_v<D> && same_as<D, remove_cv_t<D>>
94 class view_interface;
zoecarver671223d2021-05-26 14:25:02 -070095
Christopher Di Bella3cf5ef82021-07-17 01:35:42 +000096 // [range.subrange], sub-ranges
97 enum class subrange_kind : bool { unsized, sized };
98
99 template<input_or_output_iterator I, sentinel_for<I> S = I, subrange_kind K = see below>
100 requires (K == subrange_kind::sized || !sized_sentinel_for<S, I>)
101 class subrange;
102
103 template<class I, class S, subrange_kind K>
104 inline constexpr bool enable_borrowed_range<subrange<I, S, K>> = true;
105
zoecarver671223d2021-05-26 14:25:02 -0700106 // [range.empty], empty view
107 template<class T>
108 requires is_object_v<T>
109 class empty_view;
zoecarverb9f7b7a2021-06-24 11:05:50 -0700110
Louis Dionneaab9b222021-07-12 09:55:00 -0400111 // [range.all], all view
112 namespace views {
113 inline constexpr unspecified all = unspecified;
114
115 template<viewable_range R>
116 using all_t = decltype(all(declval<R>()));
117 }
118
119 template<range R>
120 requires is_object_v<R>
121 class ref_view;
122
123 template<class T>
124 inline constexpr bool enable_borrowed_range<ref_view<T>> = true;
125
zoecarverb9f7b7a2021-06-24 11:05:50 -0700126 // [range.drop], drop view
127 template<view V>
128 class drop_view;
129
130 template<class T>
131 inline constexpr bool enable_borrowed_range<drop_view<T>> = enable_borrowed_range<T>;
zoecarverae914482021-07-09 10:12:16 -0700132
133 // [range.transform], transform view
134 template<input_range V, copy_constructible F>
135 requires view<V> && is_object_v<F> &&
136 regular_invocable<F&, range_reference_t<V>> &&
137 can-reference<invoke_result_t<F&, range_reference_t<V>>>
138 class transform_view;
139
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100140}
141
142*/
143
144#include <__config>
Christopher Di Bella66ce1292021-04-11 05:08:32 +0000145#include <__ranges/access.h>
zoecarver982808d2021-05-06 15:31:45 -0700146#include <__ranges/all.h>
Christopher Di Bella9db3ef22021-04-11 17:40:30 +0000147#include <__ranges/concepts.h>
zoecarver2fbc4d22021-04-23 15:22:18 -0700148#include <__ranges/data.h>
zoecarver545d1d42021-05-06 17:39:53 -0700149#include <__ranges/drop_view.h>
zoecarver85d69332021-04-23 12:34:22 -0700150#include <__ranges/empty.h>
zoecarver671223d2021-05-26 14:25:02 -0700151#include <__ranges/empty_view.h>
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100152#include <__ranges/enable_borrowed_range.h>
Christopher Di Bella46f4bcf2021-06-10 18:40:21 +0000153#include <__ranges/enable_view.h>
zoecarverdd772db2021-05-06 13:19:13 -0700154#include <__ranges/ref_view.h>
zoecarvere3a4b182021-04-22 09:29:02 -0700155#include <__ranges/size.h>
zoecarverbd0551d2021-05-03 14:37:42 -0700156#include <__ranges/subrange.h>
zoecarverae914482021-07-09 10:12:16 -0700157#include <__ranges/transform_view.h>
zoecarver528b66d2021-04-30 15:24:28 -0700158#include <__ranges/view_interface.h>
Mark de Weveraf59b2d2020-11-24 18:08:02 +0100159#include <compare> // Required by the standard.
160#include <initializer_list> // Required by the standard.
161#include <iterator> // Required by the standard.
162#include <type_traits>
163#include <version>
164
165#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
166#pragma GCC system_header
167#endif
168
169_LIBCPP_PUSH_MACROS
170#include <__undef_macros>
171
172_LIBCPP_BEGIN_NAMESPACE_STD
173
174#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
175
176#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES)
177
178_LIBCPP_END_NAMESPACE_STD
179
180_LIBCPP_POP_MACROS
181
182#endif // _LIBCPP_RANGES