This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Strange stream behaviour


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]