Created on 2001-06-07.00:00:00 last changed 172 months ago
Rationale:
The LWG considered two options: change all of the language that seems to imply that output iterators have value types, thus making it clear that output iterators have no value types, or else define value types for output iterator consistently. The LWG chose the former option, because it seems clear that output iterators were never intended to have value types. This was a deliberate design decision, and any language suggesting otherwise is simply a mistake.
A future revision of the standard may wish to revisit this design decision.
[ post-Redmond: Jeremy provided wording ]
Proposed resolution:
24.1 p1, change
All iterators i support the expression *i, resulting in a value of some class, enumeration, or built-in type T, called the value type of the iterator.
to
All input iterators i support the expression *i, resulting in a value of some class, enumeration, or built-in type T, called the value type of the iterator. All output iterators support the expression *i = o where o is a value of some type that is in the set of types that are writable to the particular iterator type of i.
24.1 p9, add
o denotes a value of some type that is writable to the output iterator.
Table 73, change
*a = t
to
*r = o
and change
*r++ = t
to
*r++ = o
Table 73 suggests that output iterators have value types. It requires the expression "*a = t". Additionally, although Table 73 never lists "a = t" or "X(a) = t" in the "expressions" column, it contains a note saying that "a = t" and "X(a) = t" have equivalent (but nowhere specified!) semantics.
According to 24.1/9, t is supposed to be "a value of value type T":
In the following sections, a and b denote values of X, n denotes a value of the difference type Distance, u, tmp, and m denote identifiers, r denotes a value of X&, t denotes a value of value type T.
Two other parts of the standard that are relevant to whether output iterators have value types:
The first of these passages suggests that "*i" is supposed to return a useful value, which contradicts the note in 24.1.2/2 saying that the only valid use of "*i" for output iterators is in an expression of the form "*i = t". The second of these passages appears to contradict Table 73, because it suggests that "*i"'s return value should be void. The second passage is also broken in the case of a an iterator type, like non-const pointers, that satisfies both the output iterator requirements and the forward iterator requirements.
What should the standard say about *i's return value when i is an output iterator, and what should it say about that t is in the expression "*i = t"? Finally, should the standard say anything about output iterators' pointer and reference types?
History | |||
---|---|---|---|
Date | User | Action | Args |
2010-10-21 18:28:33 | admin | set | messages: + msg2237 |
2010-10-21 18:28:33 | admin | set | messages: + msg2236 |
2010-10-21 18:28:33 | admin | set | messages: + msg2235 |
2001-06-07 00:00:00 | admin | create |