Strange stream behaviour

Gabriel Dos Reis gdr@codesourcery.com
Sun Oct 7 07:30:00 GMT 2001


Jason Merrill <jason_merrill@redhat.com> writes:

| >>>>> "Nathan" == Nathan Myers <ncm@nospam.cantrip.org> writes:
| 
| > There is no reason to expect the program to work.  In particular, the 
| > function cin.get() can never return EOF under any circumstances.  EOF 
| > is an int constant, where cin.get() can only return character values.
| 
| Gosh, that seems like a big ol' trap for new users.  Is EOF checking a
| casualty of templatization?

I think the canonical way to check for end-of-file uses 

	typedef std::char_traits<character-type> char_traits;
	if (char_traits::eq_int_type(characrter, char_traits::eof()))
          ...

which operates on the "integer"-type representation of characters.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com



More information about the Libstdc++ mailing list