eofbit, failbit and badbit are member constants with implementation-defined values that can be combined (as if with the bitwise OR operator).goodbit is zero, indicating that none of the other bits is set.

In this example, myfile is open for input operations, but we perform an output operation on it, so failbit is set. The example calls then clear in order to remove the flag and allow further operations like getline to be attempted on myfile.

Data races

Modifies the stream object.
Concurrent access to the same stream object may cause data races.

Exception safety

Basic guarantee: if an exception is thrown, the stream is in a valid state.
It throws an exception of member type failure if the resulting error state flag is not goodbit and member exceptions was set throw for that state.