bug in istream.get(b,c,d)? (No.)
Mark J. Reed
mark.reed@turner.com
Wed Sep 18 14:22:00 GMT 2002
On 2002-09-18 at 16:43:41, Mark J. Reed wrote:
> If a get(buffer, count, delim) call reads 0 characters
> (because the next character on the stream is a delimiter),
> then a subsequent call to get(void) returns EOF even though
> there are more characters on the stream to be read.
Okay, so it's not a bug. From Stroustrop (special edition),
section 21.3.4:
"If a get() or getline() function doesn't read and remove
at least one character from the stream, setstate(failbit)
is called, so that subsequent reads from the stream will fail".
It still seems like this is a poor design for the three-argument
get(), which can quite legitimately not read and remove anything
without anything being wrong with the stream. I guess a solution
is to use getline(), although detecting whether or not getline()
read and removed a '\n' in the case where it reads exactly the
specified number of characters seems less than straightforward.
Anyway, sorry to have bothered you with a non-bug.
--
Mark REED | CNN Internet Technology
1 CNN Center Rm SW0831G | mark.reed@cnn.com
Atlanta, GA 30348 USA | +1 404 827 4754
--
Thirty white horses on a red hill,
First they champ,
Then they stamp,
Then they stand still.
-- Tolkien
More information about the Libstdc++
mailing list