tmp/tmpxe4xxy2v/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### C++17 iterator requirements <a id="iterator.cpp17">[[iterator.cpp17]]</a>
|
| 2 |
+
|
| 3 |
+
In the following sections, `a` and `b` denote values of type `X` or
|
| 4 |
+
`const X`, `difference_type` and `reference` refer to the types
|
| 5 |
+
`iterator_traits<X>::difference_type` and
|
| 6 |
+
`iterator_traits<X>::reference`, respectively, `n` denotes a value of
|
| 7 |
+
`difference_type`, `u`, `tmp`, and `m` denote identifiers, `r` denotes a
|
| 8 |
+
value of `X&`, `t` denotes a value of value type `T`, `o` denotes a
|
| 9 |
+
value of some type that is writable to the output iterator.
|
| 10 |
+
|
| 11 |
+
[*Note 1*: For an iterator type `X` there must be an instantiation of
|
| 12 |
+
`iterator_traits<X>` [[iterator.traits]]. — *end note*]
|
| 13 |
+
|
| 14 |
+
#### *Cpp17Iterator* <a id="iterator.iterators">[[iterator.iterators]]</a>
|
| 15 |
+
|
| 16 |
+
The *Cpp17Iterator* requirements form the basis of the iterator
|
| 17 |
+
taxonomy; every iterator meets the *Cpp17Iterator* requirements. This
|
| 18 |
+
set of requirements specifies operations for dereferencing and
|
| 19 |
+
incrementing an iterator. Most algorithms will require additional
|
| 20 |
+
operations to read [[input.iterators]] or write [[output.iterators]]
|
| 21 |
+
values, or to provide a richer set of iterator movements (
|
| 22 |
+
[[forward.iterators]], [[bidirectional.iterators]],
|
| 23 |
+
[[random.access.iterators]]).
|
| 24 |
+
|
| 25 |
+
A type `X` meets the *Cpp17Iterator* requirements if:
|
| 26 |
+
|
| 27 |
+
- `X` meets the *Cpp17CopyConstructible*, *Cpp17CopyAssignable*, and
|
| 28 |
+
*Cpp17Destructible* requirements [[utility.arg.requirements]] and
|
| 29 |
+
lvalues of type `X` are swappable [[swappable.requirements]], and
|
| 30 |
+
- `iterator_traits<X>::difference_type` is a signed integer type or
|
| 31 |
+
`void`, and
|
| 32 |
+
- the expressions in [[iterator]] are valid and have the indicated
|
| 33 |
+
semantics.
|
| 34 |
+
|
| 35 |
+
#### Input iterators <a id="input.iterators">[[input.iterators]]</a>
|
| 36 |
+
|
| 37 |
+
A class or pointer type `X` meets the requirements of an input iterator
|
| 38 |
+
for the value type `T` if `X` meets the *Cpp17Iterator*
|
| 39 |
+
[[iterator.iterators]] and *Cpp17EqualityComparable* (
|
| 40 |
+
[[cpp17.equalitycomparable]]) requirements and the expressions in
|
| 41 |
+
[[inputiterator]] are valid and have the indicated semantics.
|
| 42 |
+
|
| 43 |
+
In [[inputiterator]], the term *the domain of `==`* is used in the
|
| 44 |
+
ordinary mathematical sense to denote the set of values over which `==`
|
| 45 |
+
is (required to be) defined. This set can change over time. Each
|
| 46 |
+
algorithm places additional requirements on the domain of `==` for the
|
| 47 |
+
iterator values it uses. These requirements can be inferred from the
|
| 48 |
+
uses that algorithm makes of `==` and `!=`.
|
| 49 |
+
|
| 50 |
+
[*Example 1*: The call `find(a,b,x)` is defined only if the value of
|
| 51 |
+
`a` has the property *p* defined as follows: `b` has property *p* and a
|
| 52 |
+
value `i` has property *p* if (`*i==x`) or if (`*i!=x` and `++i` has
|
| 53 |
+
property *p*). — *end example*]
|
| 54 |
+
|
| 55 |
+
[*Note 1*: For input iterators, `a == b` does not imply `++a == ++b`.
|
| 56 |
+
(Equality does not guarantee the substitution property or referential
|
| 57 |
+
transparency.) Algorithms on input iterators should never attempt to
|
| 58 |
+
pass through the same iterator twice. They should be *single pass*
|
| 59 |
+
algorithms. Value type `T` is not required to be a *Cpp17CopyAssignable*
|
| 60 |
+
type ([[cpp17.copyassignable]]). These algorithms can be used with
|
| 61 |
+
istreams as the source of the input data through the `istream_iterator`
|
| 62 |
+
class template. — *end note*]
|
| 63 |
+
|
| 64 |
+
#### Output iterators <a id="output.iterators">[[output.iterators]]</a>
|
| 65 |
+
|
| 66 |
+
A class or pointer type `X` meets the requirements of an output iterator
|
| 67 |
+
if `X` meets the *Cpp17Iterator* requirements [[iterator.iterators]] and
|
| 68 |
+
the expressions in [[outputiterator]] are valid and have the indicated
|
| 69 |
+
semantics.
|
| 70 |
+
|
| 71 |
+
[*Note 1*: The only valid use of an `operator*` is on the left side of
|
| 72 |
+
the assignment statement. Assignment through the same value of the
|
| 73 |
+
iterator happens only once. Algorithms on output iterators should never
|
| 74 |
+
attempt to pass through the same iterator twice. They should be
|
| 75 |
+
single-pass algorithms. Equality and inequality might not be
|
| 76 |
+
defined. — *end note*]
|
| 77 |
+
|
| 78 |
+
#### Forward iterators <a id="forward.iterators">[[forward.iterators]]</a>
|
| 79 |
+
|
| 80 |
+
A class or pointer type `X` meets the requirements of a forward iterator
|
| 81 |
+
if
|
| 82 |
+
|
| 83 |
+
- `X` meets the *Cpp17InputIterator* requirements [[input.iterators]],
|
| 84 |
+
- `X` meets the *Cpp17DefaultConstructible* requirements
|
| 85 |
+
[[utility.arg.requirements]],
|
| 86 |
+
- if `X` is a mutable iterator, `reference` is a reference to `T`; if
|
| 87 |
+
`X` is a constant iterator, `reference` is a reference to `const T`,
|
| 88 |
+
- the expressions in [[forwarditerator]] are valid and have the
|
| 89 |
+
indicated semantics, and
|
| 90 |
+
- objects of type `X` offer the multi-pass guarantee, described below.
|
| 91 |
+
|
| 92 |
+
The domain of `==` for forward iterators is that of iterators over the
|
| 93 |
+
same underlying sequence. However, value-initialized iterators may be
|
| 94 |
+
compared and shall compare equal to other value-initialized iterators of
|
| 95 |
+
the same type.
|
| 96 |
+
|
| 97 |
+
[*Note 1*: Value-initialized iterators behave as if they refer past the
|
| 98 |
+
end of the same empty sequence. — *end note*]
|
| 99 |
+
|
| 100 |
+
Two dereferenceable iterators `a` and `b` of type `X` offer the
|
| 101 |
+
*multi-pass guarantee* if:
|
| 102 |
+
|
| 103 |
+
- `a == b` implies `++a == ++b` and
|
| 104 |
+
- `X` is a pointer type or the expression `(void)++X(a), *a` is
|
| 105 |
+
equivalent to the expression `*a`.
|
| 106 |
+
|
| 107 |
+
[*Note 2*: The requirement that `a == b` implies `++a == ++b` (which is
|
| 108 |
+
not true for input and output iterators) and the removal of the
|
| 109 |
+
restrictions on the number of the assignments through a mutable iterator
|
| 110 |
+
(which applies to output iterators) allows the use of multi-pass
|
| 111 |
+
one-directional algorithms with forward iterators. — *end note*]
|
| 112 |
+
|
| 113 |
+
If `a` and `b` are equal, then either `a` and `b` are both
|
| 114 |
+
dereferenceable or else neither is dereferenceable.
|
| 115 |
+
|
| 116 |
+
If `a` and `b` are both dereferenceable, then `a == b` if and only if
|
| 117 |
+
`*a` and `*b` are bound to the same object.
|
| 118 |
+
|
| 119 |
+
#### Bidirectional iterators <a id="bidirectional.iterators">[[bidirectional.iterators]]</a>
|
| 120 |
+
|
| 121 |
+
A class or pointer type `X` meets the requirements of a bidirectional
|
| 122 |
+
iterator if, in addition to meeting the *Cpp17ForwardIterator*
|
| 123 |
+
requirements, the following expressions are valid as shown in
|
| 124 |
+
[[bidirectionaliterator]].
|
| 125 |
+
|
| 126 |
+
[*Note 1*: Bidirectional iterators allow algorithms to move iterators
|
| 127 |
+
backward as well as forward. — *end note*]
|
| 128 |
+
|
| 129 |
+
#### Random access iterators <a id="random.access.iterators">[[random.access.iterators]]</a>
|
| 130 |
+
|
| 131 |
+
A class or pointer type `X` meets the requirements of a random access
|
| 132 |
+
iterator if, in addition to meeting the *Cpp17BidirectionalIterator*
|
| 133 |
+
requirements, the following expressions are valid as shown in
|
| 134 |
+
[[randomaccessiterator]].
|
| 135 |
+
|