From -3637884044005910203
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,91e745a5e99644a9
X-Google-Attributes: gidf78e5,public
From: bkline@cortex.nlm.nih.gov (Bob Kline Phoenix Contract)
Subject: Re: Is the exception behaviour of iostreams Implementation defined?
Date: 1995/06/13
Message-ID: <1995Jun13.160055.5592@nlm.nih.gov>#1/1
X-Deja-AN: 104335485
sender: news@nlm.nih.gov
references: <3r85ii$a69@godzilla.zeta.org.au>
organization: National Library of Medicine
newsgroups: comp.std.c++

greghunt@zeta.org.au wrote:
: The draft at Table 72 (27-16) shows that ios_base construction sets (in some
: way) exceptions() to goodbit.  I assume that this means that no setstate() 
: operation on the base class will throw and exception.

: At 27.4.4.3 iostate exceptions() const; indicates which iostates may cause
: exceptions to be thrown.

: Elsewhere (27.6.1.2.2 para 2 for example) it says that setstate(failbit) may
: throw an ios_base::failure exception.  Again at 27.6.1.3 para 2 basic_istream
: may call setstate() at eof and thus possibly throw an exception.

: Is the mapping between states and exceptions implementation defined?  Where
: is it set?  Personally I am not fond of file system behaviour that treats
: eof as an exception but I can't see how I can know in advance what the
: exception behaviour is going to be.  

: Can anyone clarify this for me?  Have I missed something?

If I understand this section of the DWP correctly, the programmer
has control over which states trigger exceptions by use of the second
overloaded version of the function: void exceptions(iostate except);,
with the default behavior that no state will trigger an exception.
This works out nicely, as you have the best of both worlds, unless
I've missed some subtle pitfall.  I certainly hope my understanding
is correct, as I share your distaste for an I/O package which by
default would throw an exception on eof.

--
/*----------------------------------------------------------------------*/
/* Bob Kline                                       Stream International */
/* bob_kline@stream.com               formerly Corporate Software, Inc. */
/* voice: (703) 522-0820 x-311                      fax: (703) 522-5407 */
/*----------------------------------------------------------------------*/



