This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.

485. output iterator insufficiently constrained

Section: 25.3.5.4 [output.iterators] Status: Resolved Submitter: Chris Jefferson Opened: 2004-10-13 Last modified: 2016-01-28

Priority: Not Prioritized

View other active issues in [output.iterators].

View all other issues in [output.iterators].

View all issues with Resolved status.

Discussion:

The note on 24.1.2 Output iterators insufficiently limits what can be performed on output iterators. While it requires that each iterator is progressed through only once and that each iterator is written to only once, it does not require the following things:

Note: Here it is assumed that x is an output iterator of type X which has not yet been assigned to.

a) That each value of the output iterator is written to: The standard allows: ++x; ++x; ++x;

b) That assignments to the output iterator are made in order X a(x); ++a; *a=1; *x=2; is allowed

c) Chains of output iterators cannot be constructed: X a(x); ++a; X b(a); ++b; X c(b); ++c; is allowed, and under the current wording (I believe) x,a,b,c could be written to in any order.

I do not believe this was the intension of the standard?

[Lillehammer: Real issue. There are lots of constraints we intended but didn't specify. Should be solved as part of iterator redesign.]

[ 2009-07 Frankfurt ]

Bill provided wording according to consensus.

[ 2009-07-21 Alisdair requests change from Review to Open. See thread starting with c++std-lib-24459 for discussion. ]

[ 2009-10 Santa Cruz: ]

Modified wording. Set to Review.

[ 2009-10 Santa Cruz: ]

Move to Ready after looking at again in a larger group in Santa Cruz.

[ 2010 Pittsburgh: ]

Moved to NAD EditorialResolved. Rationale added below.

Rationale:

Solved by N3066.

Proposed resolution:

Change Table 101 — Output iterator requirements in 25.3.5.4 [output.iterators]:

Table 101 — Output iterator requirements
Expression Return type Operational semantics Assertion/note pre-/post-condition
X(a)     a = t is equivalent to X(a) = t. note: a destructor is assumed.
X u(a);
X u = a;
     
*r = o result is not used   Post: r is not required to be dereferenceable. r is incrementable.
++r X&   &r == &++r Post: r is dereferenceable, unless otherwise specified. r is not required to be incrementable.
r++ convertible to const X& {X tmp = r;
++r;
return tmp;}
Post: r is dereferenceable, unless otherwise specified. r is not required to be incrementable.
*r++ = o; result is not used