This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[RFC] Doubts about our istream::ignore
- From: Paolo Carlini <pcarlini at suse dot de>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 20 May 2004 19:28:38 +0200
- Subject: [RFC] Doubts about our istream::ignore
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.