Topic: Defect Report: output iterator insufficently constrained
Author: chris <chris@bubblescope.net>
Date: Wed, 13 Oct 2004 19:38:41 +0000 (UTC) Raw View
[ Note: forwarded to C++ Committee. -sdc ]
The note on 24.1.2 Output iterators insufficently 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?
Suggested fix:
Add to the note:
"The values of an output iterator must be assigned to in the order they
are generated. It is undefined to progress forward more than once from a
value of an output iterator which has not yet been assigned."
This is I believe the intension of the existing text. The "progress
forward once" is allowed so that "*r++=t" is allowed. It may be prefered
to instead allow something more along the lines of:
"The values of an output iterator must be assigned to in the order they
are generated. With the exception of '*r++=t', an iterator must always
be assigned to before it is incremented".
Thank you,
Chris
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]