cpp/io/ios base/iostate

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

The eofbit
The eofbit is set by the following standard library functions:
 * The string input function std if it completes by reaching the end of the stream, as opposed to reaching the specified terminating character.
 * The numeric input overloads of if the end of the stream was encountered while reading the next character, on Stage 2 of  processing. Depending on the parsing state,  may or may not be set at the same time: for example,  sets, but not : the integer  was successfully parsed and stored in . On the other hand,  sets both  and : there was not enough characters to complete the parsing of the boolean.
 * The character extraction overloads of, if the end of the stream is reached before the limit (if any) on the number of characters to be extracted.
 * The std I/O manipulator and any of the std parsing functions:, , , etc., if the end of the stream is reached before the last character needed to parse the expected date/time value was processed.
 * The std I/O manipulator and function, if the end of the stream is reached before the last character needed to parse the expected monetary value was processed.
 * The constructor, executed at the beginning of every formatted input function: unless the  bit is unset (e.g. by issuing std), sentry reads and discards the leading whitespace characters. If the end of the input stream is reached during this operation, both  and  are set, and no input takes place.
 * The I/O manipulator std, if it reaches the end of the stream while consuming whitespace (but, unlike the formatted input sentry, it does not set in this case).
 * The unformatted input functions, , , , , and , when reaching the end of the stream.
 * The discard input function, when reaching the end of the stream before reaching the specified delimiter character.
 * The immediate input function, if returns.

The following functions clear as a side-effect:

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

The failbit
The failbit is set by the following standard library functions:
 * The constructor, executed at the beginning of every input function, if either  or  is already set on the stream, or if the end of stream is encountered while consuming leading whitespace.
 * The constructor, executed at the beginning of every output function, under implementation-defined conditions.
 * if the function extracts no characters from the input stream.
 * if the function fails to extract a valid complex number.
 * The character array and single character overloads of if they fail to extract any characters.
 * The streambuf overload of if the streambuf argument is a null pointer or if no characters were inserted into the streambuf.
 * The streambuf overload of if the function inserts no characters.
 * if the function extracts no characters from the input stream.
 * std if the function extracts no characters or if it manages to extract characters from the input stream.
 * The numeric, pointer, and boolean input overloads of (technically, the overloads of  they call), if the input cannot be parsed as a valid value or if the value parsed does not fit in the destination type.
 * The time input manipulator std (technically, it calls), if the input cannot be unambiguously parsed as a time value according to the given format string.
 * The currency input manipulator std (technically, it calls), if the input cannot be unambiguously parsed as a monetary value according to the locale rules.
 * The extraction operators of all s, if bad input is encountered.
 * The extraction operators of all s, if bad input is encountered.
 * The unformatted input functions if they fails to extract any characters.
 * , if it extracts no characters, if it fills in the provided buffer without encountering the delimiter, or if the provided buffer size is less than 1.
 * , if the end-of-file condition occurs on the input stream before all requested characters could be extracted.
 * on failure
 * on failure
 * The constructors of std, std, and std that takes a filename argument, if the file cannot be opened.
 * ,, and if the file cannot be opened.
 * ,, and if the file cannot be closed.

The badbit
The badbit is set by the following standard library functions:


 * if it fails to insert a character into the output stream, for any reason.
 * if it fails to insert a character into the output stream, for any reason.
 * Formatted output functions operator<<, std, and std, if they encounter the end of the output stream before completing output.
 * when called to initialize a stream with a null pointer for.
 * and when called on a stream with a null.
 * when a null pointer is passed as the argument.
 * and if  or  return.
 * ,, and every output function on a output stream, if  returns.
 * Every stream I/O function if an exception is thrown by any member function of the associated stream buffer (e.g., , , , etc).
 * and on failure (e.g. failure to allocate memory).