This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] libstdc++/14252, aka ++streamoff
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Cc: Pétur Runólfsson <peturr02 at ru dot is>
- Date: Tue, 24 Feb 2004 17:32:50 +0100
- Subject: [RFC] libstdc++/14252, aka ++streamoff
Hi,
this is an interesting bug. In std::count we are using something like:
iterator_traits<_Iterator>::difference_type __n = 0;
...
++__n;
Now, for an istreambuf_iterator, difference_type is _Traits::off_type
and the latter is by default streamoff. In positypes.h we promised to
provide:
// This implementation allows the use of operators +=, -=, ++ and
// -- on streamoff objects.
but actually ++ and -- are not there -> bummer!
Therefore, the obvious fix seems to actually add ++ and -- to streamoff.
Do you agree?
It seems to me that, since difference_type is modeled after ptrdiff_t,
an user of the type is supposed to have available those operators (besides
+= and -= which are already there, I mean).
I will be preparing a patch along those lines, if nobody objects. The
alternative, changing all the uses of input_iterator::difference_type
to avoid ++ and -- seems silly, given the rationale behind difference_type
(as I understand it, indeed!)
Paolo.