[RFC] Doubts about our istream::ignore
Paolo Carlini
pcarlini@suse.de
Thu May 20 17:27:00 GMT 2004
Hi,
I'm studying in detail our ignore, in order to eventually implement a
performance improvement similar to that suggested by Pétur for
getline(char_type*).
Various things are puzzling me...
First, right at beginning, for an __n of type streamsize, there is:
__n = std::min(__n, numeric_limits<streamsize>::max());
isn't this basically a NOP, or the headache that I have got since this
morning is obfuscating my mind?
Then, a much more subtle one. The main loop goes like this:
while (_M_gcount < __n
&& !traits_type::eq_int_type(__c = __sb->sbumpc(), __eof))
{
...
Now, according to 27.6.1.3, p24:
"... Characters are extracted until any of the following occurs:
- if n != numeric_limits<streamsize>::max(), n characters are extracted..."
But we are enforcing this rule *always*, not only when n != ... !!
In other terms, when _M_gcount becomes == __n we *always* terminate the
loop, whereas for __n == numeric_limits<streamsize>::max() we shouldn't.
Comments?
Thanks,
Paolo.
More information about the Libstdc++
mailing list