From Jason Turner

[iterator.concepts]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpgn1rhxlb/{from.md → to.md} +13 -11
tmp/tmpgn1rhxlb/{from.md → to.md} RENAMED
@@ -46,11 +46,11 @@ Types that are indirectly readable by applying `operator*` model the
46
  `indirectly_readable` concept, including pointers, smart pointers, and
47
  iterators.
48
 
49
  ``` cpp
50
  template<class In>
51
- concept indirectly-readable-impl =
52
  requires(const In in) {
53
  typename iter_value_t<In>;
54
  typename iter_reference_t<In>;
55
  typename iter_rvalue_reference_t<In>;
56
  { *in } -> same_as<iter_reference_t<In>>;
@@ -88,11 +88,11 @@ template<class Out, class T>
88
  };
89
  ```
90
 
91
  Let `E` be an expression such that `decltype((E))` is `T`, and let `o`
92
  be a dereferenceable object of type `Out`. `Out` and `T` model
93
- `indirectly_writable<Out, T>` only if
94
 
95
  - If `Out` and `T` model
96
  `indirectly_readable<Out> && same_as<iter_value_t<Out>, decay_t<T>>`,
97
  then `*o` after any above assignment is equal to the value of `E`
98
  before the assignment.
@@ -241,19 +241,19 @@ a signed-integer-like type.
241
  type. `is-signed-integer-like<I>` is `true` if and only if `I` is a
242
  signed-integer-like type.
243
 
244
  Let `i` be an object of type `I`. When `i` is in the domain of both pre-
245
  and post-increment, `i` is said to be *incrementable*. `I` models
246
- `weakly_incrementable<I>` only if
247
 
248
  - The expressions `++i` and `i++` have the same domain.
249
  - If `i` is incrementable, then both `++i` and `i++` advance `i` to the
250
  next element.
251
  - If `i` is incrementable, then `addressof(++i)` is equal to
252
  `addressof(i)`.
253
 
254
- *Recommended practice:* The implementaton of an algorithm on a weakly
255
  incrementable type should never attempt to pass through the same
256
  incrementable value twice; such an algorithm should be a single-pass
257
  algorithm.
258
 
259
  [*Note 3*: For `weakly_incrementable` types, `a` equals `b` does not
@@ -267,12 +267,13 @@ be used with istreams as the source of the input data through the
267
  The `incrementable` concept specifies requirements on types that can be
268
  incremented with the pre- and post-increment operators. The increment
269
  operations are required to be equality-preserving, and the type is
270
  required to be `equality_comparable`.
271
 
272
- [*Note 1*: This supersedes the annotations on the increment expressions
273
- in the definition of `weakly_incrementable`. *end note*]
 
274
 
275
  ``` cpp
276
  template<class I>
277
  concept incrementable =
278
  regular<I> &&
@@ -281,11 +282,11 @@ template<class I>
281
  { i++ } -> same_as<I>;
282
  };
283
  ```
284
 
285
  Let `a` and `b` be incrementable objects of type `I`. `I` models
286
- `incrementable` only if
287
 
288
  - If `bool(a == b)` then `bool(a++ == b)`.
289
  - If `bool(a == b)` then `bool(((void)a++, a) == ++b)`.
290
 
291
  [*Note 2*: The requirement that `a` equals `b` implies `++a` equals
@@ -330,11 +331,11 @@ template<class S, class I>
330
  input_or_output_iterator<I> &&
331
  weakly-equality-comparable-with<S, I>; // see [concept.equalitycomparable]
332
  ```
333
 
334
  Let `s` and `i` be values of type `S` and `I` such that \[`i`, `s`)
335
- denotes a range. Types `S` and `I` model `sentinel_for<S, I>` only if
336
 
337
  - `i == s` is well-defined.
338
  - If `bool(i != s)` then `i` is dereferenceable and \[`++i`, `s`)
339
  denotes a range.
340
  - `assignable_from<I&, S>` is either modeled or not satisfied.
@@ -364,11 +365,11 @@ template<class S, class I>
364
  ```
365
 
366
  Let `i` be an iterator of type `I`, and `s` a sentinel of type `S` such
367
  that \[`i`, `s`) denotes a range. Let N be the smallest number of
368
  applications of `++i` necessary to make `bool(i == s)` be `true`. `S`
369
- and `I` model `sized_sentinel_for<S, I>` only if
370
 
371
  - If N is representable by `iter_difference_t<I>`, then `s - i` is
372
  well-defined and equals N.
373
  - If -N is representable by `iter_difference_t<I>`, then `i - s` is
374
  well-defined and equals -N.
@@ -472,11 +473,11 @@ end of the same empty sequence. — *end note*]
472
  Pointers and references obtained from a forward iterator into a range
473
  \[`i`, `s`) shall remain valid while \[`i`, `s`) continues to denote a
474
  range.
475
 
476
  Two dereferenceable iterators `a` and `b` of type `X` offer the
477
- *multi-pass guarantee* if:
478
 
479
  - `a == b` implies `++a == ++b` and
480
  - the expression `((void)[](X x){++x;}(a), *a)` is equivalent to the
481
  expression `*a`.
482
 
@@ -543,11 +544,11 @@ template<class I>
543
  ```
544
 
545
  Let `a` and `b` be valid iterators of type `I` such that `b` is
546
  reachable from `a` after `n` applications of `++a`, let `D` be
547
  `iter_difference_t<I>`, and let `n` denote a value of type `D`. `I`
548
- models `random_access_iterator` only if
549
 
550
  - `(a += n)` is equal to `b`.
551
  - `addressof(a += n)` is equal to `addressof(a)`.
552
  - `(a + n)` is equal to `(a += n)`.
553
  - For any two positive values `x` and `y` of type `D`, if
@@ -587,10 +588,11 @@ non-dereferenceable iterator of type `I` such that `b` is reachable from
587
  if
588
 
589
  - `to_address(a) == addressof(*a)`,
590
  - `to_address(b) == to_address(a) + D(b - a)`,
591
  - `to_address(c) == to_address(a) + D(c - a)`,
 
592
  - `ranges::iter_move(a)` has the same type, value category, and effects
593
  as `std::move(*a)`, and
594
  - if `ranges::iter_swap(a, b)` is well-formed, it has effects equivalent
595
  to `ranges::swap(*a, *b)`.
596
 
 
46
  `indirectly_readable` concept, including pointers, smart pointers, and
47
  iterators.
48
 
49
  ``` cpp
50
  template<class In>
51
+ concept indirectly-readable-impl = // exposition only
52
  requires(const In in) {
53
  typename iter_value_t<In>;
54
  typename iter_reference_t<In>;
55
  typename iter_rvalue_reference_t<In>;
56
  { *in } -> same_as<iter_reference_t<In>>;
 
88
  };
89
  ```
90
 
91
  Let `E` be an expression such that `decltype((E))` is `T`, and let `o`
92
  be a dereferenceable object of type `Out`. `Out` and `T` model
93
+ `indirectly_writable<Out, T>` only if:
94
 
95
  - If `Out` and `T` model
96
  `indirectly_readable<Out> && same_as<iter_value_t<Out>, decay_t<T>>`,
97
  then `*o` after any above assignment is equal to the value of `E`
98
  before the assignment.
 
241
  type. `is-signed-integer-like<I>` is `true` if and only if `I` is a
242
  signed-integer-like type.
243
 
244
  Let `i` be an object of type `I`. When `i` is in the domain of both pre-
245
  and post-increment, `i` is said to be *incrementable*. `I` models
246
+ `weakly_incrementable<I>` only if:
247
 
248
  - The expressions `++i` and `i++` have the same domain.
249
  - If `i` is incrementable, then both `++i` and `i++` advance `i` to the
250
  next element.
251
  - If `i` is incrementable, then `addressof(++i)` is equal to
252
  `addressof(i)`.
253
 
254
+ *Recommended practice:* The implementation of an algorithm on a weakly
255
  incrementable type should never attempt to pass through the same
256
  incrementable value twice; such an algorithm should be a single-pass
257
  algorithm.
258
 
259
  [*Note 3*: For `weakly_incrementable` types, `a` equals `b` does not
 
267
  The `incrementable` concept specifies requirements on types that can be
268
  incremented with the pre- and post-increment operators. The increment
269
  operations are required to be equality-preserving, and the type is
270
  required to be `equality_comparable`.
271
 
272
+ [*Note 1*: This supersedes the “not required to be equality-preserving”
273
+ comments on the increment expressions in the definition of
274
+ `weakly_incrementable`. — *end note*]
275
 
276
  ``` cpp
277
  template<class I>
278
  concept incrementable =
279
  regular<I> &&
 
282
  { i++ } -> same_as<I>;
283
  };
284
  ```
285
 
286
  Let `a` and `b` be incrementable objects of type `I`. `I` models
287
+ `incrementable` only if:
288
 
289
  - If `bool(a == b)` then `bool(a++ == b)`.
290
  - If `bool(a == b)` then `bool(((void)a++, a) == ++b)`.
291
 
292
  [*Note 2*: The requirement that `a` equals `b` implies `++a` equals
 
331
  input_or_output_iterator<I> &&
332
  weakly-equality-comparable-with<S, I>; // see [concept.equalitycomparable]
333
  ```
334
 
335
  Let `s` and `i` be values of type `S` and `I` such that \[`i`, `s`)
336
+ denotes a range. Types `S` and `I` model `sentinel_for<S, I>` only if:
337
 
338
  - `i == s` is well-defined.
339
  - If `bool(i != s)` then `i` is dereferenceable and \[`++i`, `s`)
340
  denotes a range.
341
  - `assignable_from<I&, S>` is either modeled or not satisfied.
 
365
  ```
366
 
367
  Let `i` be an iterator of type `I`, and `s` a sentinel of type `S` such
368
  that \[`i`, `s`) denotes a range. Let N be the smallest number of
369
  applications of `++i` necessary to make `bool(i == s)` be `true`. `S`
370
+ and `I` model `sized_sentinel_for<S, I>` only if:
371
 
372
  - If N is representable by `iter_difference_t<I>`, then `s - i` is
373
  well-defined and equals N.
374
  - If -N is representable by `iter_difference_t<I>`, then `i - s` is
375
  well-defined and equals -N.
 
473
  Pointers and references obtained from a forward iterator into a range
474
  \[`i`, `s`) shall remain valid while \[`i`, `s`) continues to denote a
475
  range.
476
 
477
  Two dereferenceable iterators `a` and `b` of type `X` offer the
478
+ *multi-pass guarantee* if
479
 
480
  - `a == b` implies `++a == ++b` and
481
  - the expression `((void)[](X x){++x;}(a), *a)` is equivalent to the
482
  expression `*a`.
483
 
 
544
  ```
545
 
546
  Let `a` and `b` be valid iterators of type `I` such that `b` is
547
  reachable from `a` after `n` applications of `++a`, let `D` be
548
  `iter_difference_t<I>`, and let `n` denote a value of type `D`. `I`
549
+ models `random_access_iterator` only if:
550
 
551
  - `(a += n)` is equal to `b`.
552
  - `addressof(a += n)` is equal to `addressof(a)`.
553
  - `(a + n)` is equal to `(a += n)`.
554
  - For any two positive values `x` and `y` of type `D`, if
 
588
  if
589
 
590
  - `to_address(a) == addressof(*a)`,
591
  - `to_address(b) == to_address(a) + D(b - a)`,
592
  - `to_address(c) == to_address(a) + D(c - a)`,
593
+ - `to_address(I{})` is well-defined,
594
  - `ranges::iter_move(a)` has the same type, value category, and effects
595
  as `std::move(*a)`, and
596
  - if `ranges::iter_swap(a, b)` is well-formed, it has effects equivalent
597
  to `ranges::swap(*a, *b)`.
598