This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]