This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofCD1 status.
Section: 24.3.5.4[output.iterators]Status:CD1Submitter: Dave AbrahamsOpened: 2001-06-07Last modified: 2016-01-28
Priority:Not Prioritized
View otheractive issues in [output.iterators].
View all otherissues in [output.iterators].
View all issues withCD1 status.
Discussion:
Table 73 suggests that output iterators have value types. It requires the expression "*a = t". Additionally, although Table 73never lists "a = t" or "X(a) = t" in the "expressions" column, itcontains 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 typeT":
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 whetheroutput iterators have value types:
The first of these passages suggests that "*i" is supposed toreturn a useful value, which contradicts the note in 24.1.2/2 sayingthat the only valid use of "*i" for output iterators is in anexpression of the form "*i = t". The second of these passages appearsto contradict Table 73, because it suggests that "*i"'s return valueshould be void. The second passage is also broken in the case of a aniterator type, like non-const pointers, that satisfies both the outputiterator requirements and the forward iterator requirements.
What should the standard say about*i
's return value wheni is an output iterator, and what should it say about that t is in theexpression "*i = t"? Finally, should the standard say anything aboutoutput iterators' pointer and reference types?
Proposed resolution:
24.1 p1, change
All iterators
i
support the expression*i
, resultingin a value of some class, enumeration, or built-in typeT
,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 typeT
, called the value type of the iterator. All outputiterators support the expression*i = o
whereo
is avalue of some type that is in the set of types that arewritable tothe particular iterator type ofi
.
24.1 p9, add
o
denotes a value of some type that is writable to theoutput iterator.
Table 73, change
*a = t
to
*r = o
and change
*r++ = t
to
*r++ = o
[post-Redmond: Jeremy provided wording]
Rationale:
The LWG considered two options: change all of the language thatseems to imply that output iterators have value types, thus making itclear that output iterators have no value types, or else define valuetypes for output iterator consistently. The LWG chose the formeroption, because it seems clear that output iterators were neverintended 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 designdecision.