c***@gmail.com
2007-05-25 08:09:08 UTC
Hello group,
I'm writing a lexer taking input from a character stream. For testing
purposes, I frequently use std::stringstream, since it's easy to get
the input I want to test my lexer with.
I expected something like this:
stringstream ss("");
assert (ss.eof());
But it turns out not to be true. However, this works:
stringstream ss("");
ss.peek();
assert (ss.eof());
I am surprised. This forces me to call peek() when I start lexing,
which I fell is a hack.
So since ss.peek() is not supposed to change the stream, how come
eof() returns different results? Is this my implementation (GCC
3.4.5.) or is it standard?
Carl
I'm writing a lexer taking input from a character stream. For testing
purposes, I frequently use std::stringstream, since it's easy to get
the input I want to test my lexer with.
I expected something like this:
stringstream ss("");
assert (ss.eof());
But it turns out not to be true. However, this works:
stringstream ss("");
ss.peek();
assert (ss.eof());
I am surprised. This forces me to call peek() when I start lexing,
which I fell is a hack.
So since ss.peek() is not supposed to change the stream, how come
eof() returns different results? Is this my implementation (GCC
3.4.5.) or is it standard?
Carl
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]