This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: std::istream_iterator and eofbit
- To: libstdc++ at gcc dot gnu dot org
- Subject: Re: std::istream_iterator and eofbit
- From: Bill Somerville <bill at classdesign dot com>
- Date: Fri, 29 Jun 2001 18:35:29 +0100
- Organization: Class Design Limited
- References: <3B3CB0F4.B285E98C@classdesign.com>
Bill Somerville wrote:
> Hi
>
> The ISO Standard and the v3.0 implementation agree that eofbit doesn't
> constitute an end-of-stream condition, why is this?
>
> If you use std::istream_iterator to form an input range to an algorithm,
> then an infinte loop ensues if eofbit gets set, are stream exceptions
> supposed to be used to terminate such loops?
>
OK its not quite as bad as I thought, I was testing for good() at the start
of my user defined extractor and exiting is the result was false (I now
realise that I should make sure failbit is set). This is
not a good idea! Still the original question stands although it doesn't
cause an infinite loop is good() is not used as a stream validation method
in extractors.
> --
> Bill Somerville
--
Bill Somerville