[RFC] libstdc++/14252, aka ++streamoff
Paolo Carlini
pcarlini@suse.de
Tue Feb 24 16:32:00 GMT 2004
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.
More information about the Libstdc++
mailing list