From Jason Turner

[range.access]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp9gwynwtt/{from.md → to.md} +353 -0
tmp/tmp9gwynwtt/{from.md → to.md} RENAMED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Range access <a id="range.access">[[range.access]]</a>
2
+
3
+ In addition to being available via inclusion of the `<ranges>` header,
4
+ the customization point objects in [[range.access]] are available when
5
+ `<iterator>` is included.
6
+
7
+ Within this subclause, the *reified object* of a subexpression `E`
8
+ denotes
9
+
10
+ - the same object as `E` if `E` is a glvalue, or
11
+ - the result of applying the temporary materialization conversion
12
+ [[conv.rval]] to `E` otherwise.
13
+
14
+ ### `ranges::begin` <a id="range.access.begin">[[range.access.begin]]</a>
15
+
16
+ The name `ranges::begin` denotes a customization point object
17
+ [[customization.point.object]].
18
+
19
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
20
+ denotes the reified object for `E`. Then:
21
+
22
+ - If `E` is an rvalue and `enable_borrowed_range<remove_cv_t<T>>` is
23
+ `false`, `ranges::begin(E)` is ill-formed.
24
+ - Otherwise, if `T` is an array type [[basic.compound]] and
25
+ `remove_all_extents_t<T>` is an incomplete type, `ranges::begin(E)` is
26
+ ill-formed with no diagnostic required.
27
+ - Otherwise, if `T` is an array type, `ranges::begin(E)` is
28
+ expression-equivalent to `t + 0`.
29
+ - Otherwise, if `decay-copy(t.begin())` is a valid expression whose type
30
+ models `input_or_output_iterator`, `ranges::begin(E)` is
31
+ expression-equivalent to `decay-copy(t.begin())`.
32
+ - Otherwise, if `T` is a class or enumeration type and
33
+ `decay-copy(begin(t))` is a valid expression whose type models
34
+ `input_or_output_iterator` with overload resolution performed in a
35
+ context in which unqualified lookup for `begin` finds only the
36
+ declarations
37
+ ``` cpp
38
+ void begin(auto&) = delete;
39
+ void begin(const auto&) = delete;
40
+ ```
41
+
42
+ then `ranges::begin(E)` is expression-equivalent to
43
+ `decay-copy(begin(t))` with overload resolution performed in the above
44
+ context.
45
+ - Otherwise, `ranges::begin(E)` is ill-formed.
46
+
47
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
48
+ failure when `ranges::begin(E)` appears in the immediate context of a
49
+ template instantiation. — *end note*]
50
+
51
+ [*Note 2*: Whenever `ranges::begin(E)` is a valid expression, its type
52
+ models `input_or_output_iterator`. — *end note*]
53
+
54
+ ### `ranges::end` <a id="range.access.end">[[range.access.end]]</a>
55
+
56
+ The name `ranges::end` denotes a customization point object
57
+ [[customization.point.object]].
58
+
59
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
60
+ denotes the reified object for `E`. Then:
61
+
62
+ - If `E` is an rvalue and `enable_borrowed_range<remove_cv_t<T>>` is
63
+ `false`, `ranges::end(E)` is ill-formed.
64
+ - Otherwise, if `T` is an array type [[basic.compound]] and
65
+ `remove_all_extents_t<T>` is an incomplete type, `ranges::end(E)` is
66
+ ill-formed with no diagnostic required.
67
+ - Otherwise, if `T` is an array of unknown bound, `ranges::end(E)` is
68
+ ill-formed.
69
+ - Otherwise, if `T` is an array, `ranges::end(E)` is
70
+ expression-equivalent to `t + extent_v<T>`.
71
+ - Otherwise, if `decay-copy(t.end())` is a valid expression whose type
72
+ models `sentinel_for<iterator_t<T>>` then `ranges::end(E)` is
73
+ expression-equivalent to `decay-copy(t.end())`.
74
+ - Otherwise, if `T` is a class or enumeration type and
75
+ `decay-copy(end(t))` is a valid expression whose type models
76
+ `sentinel_for<iterator_t<T>>` with overload resolution performed in a
77
+ context in which unqualified lookup for `end` finds only the
78
+ declarations
79
+ ``` cpp
80
+ void end(auto&) = delete;
81
+ void end(const auto&) = delete;
82
+ ```
83
+
84
+ then `ranges::end(E)` is expression-equivalent to `decay-copy(end(t))`
85
+ with overload resolution performed in the above context.
86
+ - Otherwise, `ranges::end(E)` is ill-formed.
87
+
88
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
89
+ failure when `ranges::end(E)` appears in the immediate context of a
90
+ template instantiation. — *end note*]
91
+
92
+ [*Note 2*: Whenever `ranges::end(E)` is a valid expression, the types
93
+ `S` and `I` of `ranges::end(E)` and `ranges::begin(E)` model
94
+ `sentinel_for<S, I>`. — *end note*]
95
+
96
+ ### `ranges::cbegin` <a id="range.access.cbegin">[[range.access.cbegin]]</a>
97
+
98
+ The name `ranges::cbegin` denotes a customization point object
99
+ [[customization.point.object]]. The expression `ranges::{}cbegin(E)` for
100
+ a subexpression `E` of type `T` is expression-equivalent to:
101
+
102
+ - `ranges::begin(static_cast<const T&>(E))` if `E` is an lvalue.
103
+ - Otherwise, `ranges::begin(static_cast<const T&&>(E))`.
104
+
105
+ [*Note 1*: Whenever `ranges::cbegin(E)` is a valid expression, its type
106
+ models `input_or_output_iterator`. — *end note*]
107
+
108
+ ### `ranges::cend` <a id="range.access.cend">[[range.access.cend]]</a>
109
+
110
+ The name `ranges::cend` denotes a customization point object
111
+ [[customization.point.object]]. The expression `ranges::cend(E)` for a
112
+ subexpression `E` of type `T` is expression-equivalent to:
113
+
114
+ - `ranges::end(static_cast<const T&>(E))` if `E` is an lvalue.
115
+ - Otherwise, `ranges::end(static_cast<const T&&>(E))`.
116
+
117
+ [*Note 1*: Whenever `ranges::cend(E)` is a valid expression, the types
118
+ `S` and `I` of `ranges::cend(E)` and `ranges::cbegin(E)` model
119
+ `sentinel_for<S, I>`. — *end note*]
120
+
121
+ ### `ranges::rbegin` <a id="range.access.rbegin">[[range.access.rbegin]]</a>
122
+
123
+ The name `ranges::rbegin` denotes a customization point object
124
+ [[customization.point.object]].
125
+
126
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
127
+ denotes the reified object for `E`. Then:
128
+
129
+ - If `E` is an rvalue and `enable_borrowed_range<remove_cv_t<T>>` is
130
+ `false`, `ranges::rbegin(E)` is ill-formed.
131
+ - Otherwise, if `T` is an array type [[basic.compound]] and
132
+ `remove_all_extents_t<T>` is an incomplete type, `ranges::rbegin(E)`
133
+ is ill-formed with no diagnostic required.
134
+ - Otherwise, if `decay-copy(t.rbegin())` is a valid expression whose
135
+ type models `input_or_output_iterator`, `ranges::rbegin(E)` is
136
+ expression-equivalent to `decay-copy(t.rbegin())`.
137
+ - Otherwise, if `T` is a class or enumeration type and
138
+ `decay-copy(rbegin(t))` is a valid expression whose type models
139
+ `input_or_output_iterator` with overload resolution performed in a
140
+ context in which unqualified lookup for `rbegin` finds only the
141
+ declarations
142
+ ``` cpp
143
+ void rbegin(auto&) = delete;
144
+ void rbegin(const auto&) = delete;
145
+ ```
146
+
147
+ then `ranges::rbegin(E)` is expression-equivalent to
148
+ `decay-copy(rbegin(t))` with overload resolution performed in the
149
+ above context.
150
+ - Otherwise, if both `ranges::begin(t)` and `ranges::end(t)` are valid
151
+ expressions of the same type which models `bidirectional_iterator`
152
+ [[iterator.concept.bidir]], `ranges::rbegin(E)` is
153
+ expression-equivalent to `make_reverse_iterator(ranges::end(t))`.
154
+ - Otherwise, `ranges::rbegin(E)` is ill-formed.
155
+
156
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
157
+ failure when `ranges::rbegin(E)` appears in the immediate context of a
158
+ template instantiation. — *end note*]
159
+
160
+ [*Note 2*: Whenever `ranges::rbegin(E)` is a valid expression, its type
161
+ models `input_or_output_iterator`. — *end note*]
162
+
163
+ ### `ranges::rend` <a id="range.access.rend">[[range.access.rend]]</a>
164
+
165
+ The name `ranges::rend` denotes a customization point object
166
+ [[customization.point.object]].
167
+
168
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
169
+ denotes the reified object for `E`. Then:
170
+
171
+ - If `E` is an rvalue and `enable_borrowed_range<remove_cv_t<T>>` is
172
+ `false`, `ranges::rend(E)` is ill-formed.
173
+ - Otherwise, if `T` is an array type [[basic.compound]] and
174
+ `remove_all_extents_t<T>` is an incomplete type, `ranges::rend(E)` is
175
+ ill-formed with no diagnostic required.
176
+ - Otherwise, if `decay-copy(t.rend())` is a valid expression whose type
177
+ models `sentinel_for<decltype(ranges::rbegin(E))>` then
178
+ `ranges::rend(E)` is expression-equivalent to
179
+ `decay-copy(t.rend({}))`.
180
+ - Otherwise, if `T` is a class or enumeration type and
181
+ `decay-copy(rend(t))` is a valid expression whose type models
182
+ `sentinel_for<decltype(ranges::rbegin(E))>` with overload resolution
183
+ performed in a context in which unqualified lookup for `rend` finds
184
+ only the declarations
185
+ ``` cpp
186
+ void rend(auto&) = delete;
187
+ void rend(const auto&) = delete;
188
+ ```
189
+
190
+ then `ranges::rend(E)` is expression-equivalent to
191
+ `decay-copy(rend(t))` with overload resolution performed in the above
192
+ context.
193
+ - Otherwise, if both `ranges::begin(t)` and `ranges::end(t)` are valid
194
+ expressions of the same type which models `bidirectional_iterator`
195
+ [[iterator.concept.bidir]], then `ranges::rend(E)` is
196
+ expression-equivalent to `make_reverse_iterator(ranges::begin(t))`.
197
+ - Otherwise, `ranges::rend(E)` is ill-formed.
198
+
199
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
200
+ failure when `ranges::rend(E)` appears in the immediate context of a
201
+ template instantiation. — *end note*]
202
+
203
+ [*Note 2*: Whenever `ranges::rend(E)` is a valid expression, the types
204
+ `S` and `I` of `ranges::rend(E)` and `ranges::rbegin(E)` model
205
+ `sentinel_for<S, I>`. — *end note*]
206
+
207
+ ### `ranges::crbegin` <a id="range.access.crbegin">[[range.access.crbegin]]</a>
208
+
209
+ The name `ranges::crbegin` denotes a customization point object
210
+ [[customization.point.object]]. The expression `ranges::{}crbegin(E)`
211
+ for a subexpression `E` of type `T` is expression-equivalent to:
212
+
213
+ - `ranges::{}rbegin(static_cast<const T&>(E))` if `E` is an lvalue.
214
+ - Otherwise, `ranges::rbegin(static_cast<const T&&>(E))`.
215
+
216
+ [*Note 1*: Whenever `ranges::crbegin(E)` is a valid expression, its
217
+ type models `input_or_output_iterator`. — *end note*]
218
+
219
+ ### `ranges::crend` <a id="range.access.crend">[[range.access.crend]]</a>
220
+
221
+ The name `ranges::crend` denotes a customization point object
222
+ [[customization.point.object]]. The expression `ranges::{}crend(E)` for
223
+ a subexpression `E` of type `T` is expression-equivalent to:
224
+
225
+ - `ranges::rend(static_cast<const T&>(E))` if `E` is an lvalue.
226
+ - Otherwise, `ranges::rend(static_cast<const T&&>(E))`.
227
+
228
+ [*Note 1*: Whenever `ranges::crend(E)` is a valid expression, the types
229
+ `S` and `I` of `ranges::crend(E)` and `ranges::crbegin(E)` model
230
+ `sentinel_for<S, I>`. — *end note*]
231
+
232
+ ### `ranges::size` <a id="range.prim.size">[[range.prim.size]]</a>
233
+
234
+ The name `ranges::size` denotes a customization point object
235
+ [[customization.point.object]].
236
+
237
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
238
+ denotes the reified object for `E`. Then:
239
+
240
+ - If `T` is an array of unknown bound [[dcl.array]], `ranges::size(E)`
241
+ is ill-formed.
242
+ - Otherwise, if `T` is an array type, `ranges::size(E)` is
243
+ expression-equivalent to `decay-copy(extent_v<T>)`.
244
+ - Otherwise, if `disable_sized_range<remove_cv_t<T>>` [[range.sized]] is
245
+ `false` and `decay-copy(t.size())` is a valid expression of
246
+ integer-like type [[iterator.concept.winc]], `ranges::size(E)` is
247
+ expression-equivalent to `decay-copy(t.size())`.
248
+ - Otherwise, if `T` is a class or enumeration type,
249
+ `disable_sized_range<remove_cv_t<T>>` is `false` and
250
+ `decay-copy(size(t))` is a valid expression of integer-like type with
251
+ overload resolution performed in a context in which unqualified lookup
252
+ for `size` finds only the declarations
253
+ ``` cpp
254
+ void size(auto&) = delete;
255
+ void size(const auto&) = delete;
256
+ ```
257
+
258
+ then `ranges::size(E)` is expression-equivalent to
259
+ `decay-copy(size(t))` with overload resolution performed in the above
260
+ context.
261
+ - Otherwise, if `to-unsigned-like(ranges::end(t) - ranges::begin(t))`
262
+ [[ranges.syn]] is a valid expression and the types `I` and `S` of
263
+ `ranges::begin(t)` and `ranges::end(t)` (respectively) model both
264
+ `sized_sentinel_for<S, I>` [[iterator.concept.sizedsentinel]] and
265
+ `forward_iterator<I>`, then `ranges::size(E)` is expression-equivalent
266
+ to `to-unsigned-like(ranges::end(t) - ranges::begin(t))`.
267
+ - Otherwise, `ranges::size(E)` is ill-formed.
268
+
269
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
270
+ failure when `ranges::size(E)` appears in the immediate context of a
271
+ template instantiation. — *end note*]
272
+
273
+ [*Note 2*: Whenever `ranges::size(E)` is a valid expression, its type
274
+ is integer-like. — *end note*]
275
+
276
+ ### `ranges::ssize` <a id="range.prim.ssize">[[range.prim.ssize]]</a>
277
+
278
+ The name `ranges::ssize` denotes a customization point object
279
+ [[customization.point.object]]. The expression `ranges::ssize({}E)` for
280
+ a subexpression `E` of type `T` is expression-equivalent to:
281
+
282
+ - If `range_difference_t<T>` has width less than `ptrdiff_t`,
283
+ `static_cast<ptrdiff_t>(ranges::{}size(E))`.
284
+ - Otherwise, `static_cast<range_difference_t<T>>(ranges::size(E))`.
285
+
286
+ ### `ranges::empty` <a id="range.prim.empty">[[range.prim.empty]]</a>
287
+
288
+ The name `ranges::empty` denotes a customization point object
289
+ [[customization.point.object]].
290
+
291
+ Given a subexpression `ranges::empty(E)` with type `T`, let `t` be an
292
+ lvalue that denotes the reified object for `E`. Then:
293
+
294
+ - If `T` is an array of unknown bound [[basic.compound]],
295
+ `ranges::empty(E)` is ill-formed.
296
+ - Otherwise, if `bool(t.empty())` is a valid expression,
297
+ `ranges::empty(E)` is expression-equivalent to `bool(t.empty())`.
298
+ - Otherwise, if `(ranges::size(t) == 0)` is a valid expression,
299
+ `ranges::empty(E)` is expression-equivalent to
300
+ `(ranges::size(t) == 0)`.
301
+ - Otherwise, if `bool(ranges::begin(t) == ranges::end(t))` is a valid
302
+ expression and the type of `ranges::begin(t)` models
303
+ `forward_iterator`, `ranges::empty(E)` is expression-equivalent to
304
+ `bool({}ranges::begin(t) == ranges::end(t))`.
305
+ - Otherwise, `ranges::empty(E)` is ill-formed.
306
+
307
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
308
+ failure when `ranges::empty(E)` appears in the immediate context of a
309
+ template instantiation. — *end note*]
310
+
311
+ [*Note 2*: Whenever `ranges::empty(E)` is a valid expression, it has
312
+ type `bool`. — *end note*]
313
+
314
+ ### `ranges::data` <a id="range.prim.data">[[range.prim.data]]</a>
315
+
316
+ The name `ranges::data` denotes a customization point object
317
+ [[customization.point.object]].
318
+
319
+ Given a subexpression `E` with type `T`, let `t` be an lvalue that
320
+ denotes the reified object for `E`. Then:
321
+
322
+ - If `E` is an rvalue and `enable_borrowed_range<remove_cv_t<T>>` is
323
+ `false`, `ranges::data(E)` is ill-formed.
324
+ - Otherwise, if `T` is an array type [[basic.compound]] and
325
+ `remove_all_extents_t<T>` is an incomplete type, `ranges::data(E)` is
326
+ ill-formed with no diagnostic required.
327
+ - Otherwise, if `decay-copy(t.data())` is a valid expression of pointer
328
+ to object type, `ranges::data(E)` is expression-equivalent to
329
+ `decay-copy(t.data())`.
330
+ - Otherwise, if `ranges::begin(t)` is a valid expression whose type
331
+ models `contiguous_iterator`, `ranges::data(E)` is
332
+ expression-equivalent to `to_address(ranges::begin(E))`.
333
+ - Otherwise, `ranges::data(E)` is ill-formed.
334
+
335
+ [*Note 1*: Diagnosable ill-formed cases above result in substitution
336
+ failure when `ranges::data(E)` appears in the immediate context of a
337
+ template instantiation. — *end note*]
338
+
339
+ [*Note 2*: Whenever `ranges::data(E)` is a valid expression, it has
340
+ pointer to object type. — *end note*]
341
+
342
+ ### `ranges::cdata` <a id="range.prim.cdata">[[range.prim.cdata]]</a>
343
+
344
+ The name `ranges::cdata` denotes a customization point object
345
+ [[customization.point.object]]. The expression `ranges::{}cdata(E)` for
346
+ a subexpression `E` of type `T` is expression-equivalent to:
347
+
348
+ - `ranges::data(static_cast<const T&>(E))` if `E` is an lvalue.
349
+ - Otherwise, `ranges::data(static_cast<const T&&>(E))`.
350
+
351
+ [*Note 1*: Whenever `ranges::cdata(E)` is a valid expression, it has
352
+ pointer to object type. — *end note*]
353
+