[ios.types]

31 Input/output library [input.output]

31.5 Iostreams base classes [iostreams.base]

31.5.2 Class ios_base [ios.base]

31.5.2.2 Types [ios.types]


31.5.2.2.1 Class ios_base​::​failure [ios.failure]

31.5.2.2.2 Type ios_base​::​fmtflags [ios.fmtflags]

31.5.2.2.3 Type ios_base​::​iostate [ios.iostate]

31.5.2.2.4 Type ios_base​::​openmode [ios.openmode]

31.5.2.2.5 Type ios_base​::​seekdir [ios.seekdir]

31.5.2.2.6 Class ios_base​::​Init [ios.init]


31.5.2.2.1 Class ios_base​::​failure [ios.failure]

namespace std { class ios_base::failure : public system_error { public: explicit failure(const string& msg, const error_code& ec = io_errc::stream); explicit failure(const char* msg, const error_code& ec = io_errc::stream); }; }

An implementation is permitted to define ios_base​::​failure as a synonym for a class with equivalent functionality to class ios_base​::​failure shown in this subclause.

[Note 1:

When ios_base​::​failure is a synonym for another type, that type needs to provide a nested type failure to emulate the injected-class-name.

— end note]

The class failure defines the base class for the types of all objects thrown as exceptions, by functions in the iostreams library, to report errors detected during stream buffer operations.

When throwing ios_base​::​failure exceptions, implementations should provide values of ec that identify the specific reason for the failure.

[Note 2:

Errors arising from the operating system would typically be reported as system_category() errors with an error value of the error number reported by the operating system.

Errors arising from within the stream library would typically be reported as error_code(io_errc​::​stream, iostream_category()).

— end note]

explicit failure(const string& msg, const error_code& ec = io_errc::stream);

Effects: Constructs the base class with msg and ec.

explicit failure(const char* msg, const error_code& ec = io_errc::stream);

Effects: Constructs the base class with msg and ec.

31.5.2.2.2 Type ios_base​::​fmtflags [ios.fmtflags]

Setting its elements has the effects indicated in Table 136.

Table 136fmtflags effects [tab:ios.fmtflags]

Element

Effect(s) if set

boolalpha

insert and extract bool type in alphabetic format

dec

converts integer input or generates integer output in decimal base

fixed

generate floating-point output in fixed-point notation

hex

converts integer input or generates integer output in hexadecimal base

internal

adds fill characters at a designated internal point in certain generated output, or identical to right if no such point is designated

left

adds fill characters on the right (final positions) of certain generated output

oct

converts integer input or generates integer output in octal base

right

adds fill characters on the left (initial positions) of certain generated output

scientific

generates floating-point output in scientific notation

showbase

generates a prefix indicating the numeric base of generated integer output

showpoint

generates a decimal-point character unconditionally in generated floating-point output

showpos

generates a + sign in non-negative generated numeric output

skipws

skips leading whitespace before certain input operations

unitbuf

flushes output after each output operation

uppercase

replaces certain lowercase letters with their uppercase equivalents in generated output

Type fmtflags also defines the constants indicated in Table 137.

31.5.2.2.3 Type ios_base​::​iostate [ios.iostate]

The type iostate is a bitmask type ([bitmask.types]) that contains the elements indicated in Table 138.

Table 138iostate effects [tab:ios.iostate]

indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error from a file);

indicates that an input operation reached the end of an input sequence;

indicates that an input operation failed to read the expected characters, or that an output operation failed to generate the desired characters.

Type iostate also defines the constant:

  • goodbit, the value zero.

31.5.2.2.4 Type ios_base​::​openmode [ios.openmode]

It contains the elements indicated in Table 139.

Table 139openmode effects [tab:ios.openmode]

Element

Effect(s) if set

app

seek to end before each write

ate

open and seek to end immediately after opening

binary

perform input and output in binary mode (as opposed to text mode)

in

open for input

noreplace

open in exclusive mode

out

open for output

trunc

truncate an existing stream when opening

31.5.2.2.5 Type ios_base​::​seekdir [ios.seekdir]

The type seekdir is an enumerated type ([enumerated.types]) that contains the elements indicated in Table 140.

Table 140seekdir effects [tab:ios.seekdir]

request a seek (for subsequent input or output) relative to the beginning of the stream

request a seek relative to the current position within the sequence

request a seek relative to the current end of the sequence

31.5.2.2.6 Class ios_base​::​Init [ios.init]

namespace std { class ios_base::Init { public: Init(); Init(const Init&) = default; ~Init(); Init& operator=(const Init&) = default; }; }

The class Init describes an object whose construction ensures the construction of the eight objects declared in ([iostream.objects]) that associate file stream buffers with the standard C streams provided for by the functions declared in .

Effects: Constructs and initializes the objects cin, cout, cerr, clog, wcin, wcout, wcerr, and wclog if they have not already been constructed and initialized.

Effects: If there are no other instances of the class still in existence, calls cout.flush(), cerr.flush(), clog.flush(), wcout.flush(), wcerr.flush(), wclog.flush().