std::ios_base::iostate - cppreference.com (original) (raw)

| typedef /*implementation defined*/ iostate; | | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | | | static constexpr iostate goodbit = 0; | | | | static constexpr iostate badbit = /* implementation defined */ static constexpr iostate failbit = /* implementation defined */ static constexpr iostate eofbit = /* implementation defined */ | | |

Specifies stream state flags. It is a BitmaskType, the following constants are defined:

Constant Explanation
goodbit no error
badbit irrecoverable stream error
failbit input/output operation failed (formatting or extraction error)
eofbit associated input sequence has reached end-of-file

[edit] The eofbit

The eofbit is set by the following standard library functions:

The following functions clear eofbit as a side-effect:

Note that in nearly all situations, if eofbit is set, the failbit is set as well.

[edit] The failbit

The failbit is set by the following standard library functions:

[edit] The badbit

The badbit is set by the following standard library functions:

[edit] Example

[edit] See also

The following table shows the value of basic_ios accessors (good(), fail(), etc.) for all possible combinations of ios_base::iostate flags:

ios_base::iostate flags basic_ios accessors
eofbit failbit badbit good() fail() bad() eof() operator bool operator!
false false false true false false false true false
false false true false true true false false true
false true false false true false false false true
false true true false true true false false true
true false false false false false true true false
true false true false true true true false true
true true false false true false true false true
true true true false true true true false true

| | returns state flags (public member function of std::basic_ios<CharT,Traits>) [edit] | | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | sets state flags (public member function of std::basic_ios<CharT,Traits>) [edit] | | | modifies state flags (public member function of std::basic_ios<CharT,Traits>) [edit] |