Name

ios_base::iostate type — I/O status

Synopsis

typedef  . . .  iostate
typedef  . . .  io_state
static const iostate badbitstatic const iostate eofbit
static const iostate failbit
static const iostate goodbit = iostate(0);
image with no caption

The ios_base::iostate type is an integer, enum, or bitset type (the exact type is implementation-defined) that represents the status of an I/O stream. The io_state type is an integral type that represents the same information. Some functions that take an iostate parameter have an overloaded version that accepts an io_state parameter and has the same functionality as its iostate counterpart. The io_state type and related functions are deprecated, so you should use the iostate versions.

Table 13-15 lists the iostate literals and their meanings. The basic_ios class template has several member functions for setting, testing, and clearing iostate bits.

Table 13-15. iostate literals

Literal

Description

badbit

Irrecoverable error, such as a null streambuf pointer or a write failure

eofbit

End-of-file when reading

failbit

Failure to read or write expected characters ( e.g., trying to read an integer from nonnumeric input)

goodbit

No problems; value is 0

See Also

basic_ios class template, <bitset>

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.