 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
chris Guest
|
Posted: Thu Oct 07, 2004 3:43 pm Post subject: Possible error in the definition of output iterators |
|
|
Looking at 24.1.2 in the C++ standard, there is some strangeness with
regards output iterators.
The two main constraints appear to be:
Assignment through the same iterator happens only once.
Algorithms on output iterators should never attempt to pass through the
same iterator twice.
However, nothing is said about if a copy of an iterator is the same
iterator, or that an assignment must be made before incrementing an
iterator (as is required for example in sgi's stl implementation.
Therefore I am not clear on which of the following are legal (although I
suspect they should all be forbidden)
Given an output iterator type X, which takes ints and where a is a valid
iterator which has not yet been written to, which of the following are
allowed?
++a;
// Forbidden by sgi
X u(a); u=1; a=1;
// Probably supposed to be forbidden
X u(a); ++a; u=1;
// If this is forbidden that makes implementing the last requirement
// *r++=t difficult I suspect
X u(a); ++a; a=1; u=1;
// Is this defined? I suspect it shouldn't be
X u(a); X x(u); X y(x); X z(y);
// How far can I chain along? Which of these can I write to?
// I read the standard as saying any, in any order.
Sorry if this has been dealt with before, but I would appresiate any
comments / suggestions. Could this need a DR?
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 ]
|
|
| Back to top |
|
 |
chris Guest
|
Posted: Thu Oct 07, 2004 6:10 pm Post subject: Re: Possible error in the definition of output iterators - m |
|
|
| Quote: | Given an output iterator a ...
X u(a); X x(u); X y(x); X z(y);
|
Many apologises, when I wrote this I meant:
X u(a); ++u; X x(u); ++x; X y(x); ++y; X z(y); ++z;
Which appears to be legal to me, and I should be able to write to any of
u,x,y,z and in any order.
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 ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|