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:
| ||no error|
| ||irrecoverable stream error|
| ||input/output operation failed (formatting or extraction error)|
| ||associated input sequence has reached end-of-file|
The eofbit is set by the following standard library functions:
std::getlineif it completes by reaching the end of the stream, as opposed to reaching the specified terminating character.
basic_istream::operator>>if the end of the stream was encountered while reading the next character, on Stage 2 of
num_get::getprocessing. Depending on the parsing state,
failbitmay or may not be set at the same time: for example,
int n; istringstream buf("1"); buf >> n;sets
eofbit, but not
failbit: the integer
1was successfully parsed and stored in
n. On the other hand,
bool b; istringstream buf("tr"); buf >> boolalpha >> b;sets both
failbit: there was not enough characters to complete the parsing of the boolean
operator>>std::basic_istream, if the end of the stream is reached before the limit (if any) on the number of characters to be extracted.
std::get_timeI/O manipulator and any of the
time_get::get_date, etc., if the end of the stream is reached before the last character needed to parse the expected date/time value was processed.
std::get_moneyI/O manipulator and
money_get::getfunction, if the end of the stream is reached before the last character needed to parse the expected monetary value was processed.
basic_istream::sentryconstructor, executed at the beginning of every formatted input function: unless the
skipwsbit is unset (e.g. by issuing
std::noskipws), sentry reads and discards the leading whitespace characters. If the end of the input stream is reached during this operation, both
failbitare set, and no input takes place.
std::ws, if it reaches the end of the stream while consuming whitespace (but, unlike the formatted input sentry, it does not set
failbitin this case)
basic_istream::getline, when reaching the end of the stream.
basic_istream::ignore, when reaching the end of the stream before reaching the specified delimiter character.
The following functions clear
eofbit as a side-effect:
The failbit is set by the following standard library functions:
basic_istream::sentryconstructor, executed at the beginning of every input function, if either
badbitis already set on the stream, or if the end of stream is encountered while consuming leading whitespace.
basic_ostream::sentryconstructor, executed at the beginning of every output function, under implementation-defined conditions.
operator>>(std::basic_string<>)if the function extracts no characters from the input stream.
operator>>(std::complex<>)if the function fails to extract a valid complex number.
operator>>if they fail to extract any characters.
basic_istream::operator>>if the streambuf argument is a null pointer or if no characters were inserted into the streambuf.
basic_ostream::operator<<if the function inserts no characters.
operator>>(std::bitset<>)if the function extracts no characters from the input stream.
std::getlineif the function extracts no characters or if it manages to extract
basic_string::max_sizecharacters from the input stream.
basic_istream::operator>>(technically, the overloads of
num_get::getthey call), if the input cannot be parsed as a valid value or if the value parsed does not fit in the destination type.
time_get::getit calls), if the input cannot be unambiguously parsed as a time value according to the given format string.
money_get::getit calls), if the input cannot be unambiguously parsed as a monetary value according to the locale rules.
RandomNumberEngines, if bad input is encountered.
RandomNumberDistributions, if bad input is encountered.
basic_istream::getif they fails to extract any characters.
basic_istream::getline, 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.
basic_istream::read, if the end-of-file condition occurs on the input stream before all requested characters could be extracted.
std::basic_ofstreamthat takes a filename argument, if the file cannot be opened.
basic_ofstream::openif the file cannot be opened.
basic_ofstream::closeif the file cannot be closed.
The badbit is set by the following standard library functions:
basic_ostream::putif it fails to insert a character into the output stream, for any reason.
basic_ostream::writeif it fails to insert a character into the output stream, for any reason.
std::put_time, if they encounter the end of the output stream before completing output.
basic_ios::initwhen called to initialize a stream with a null pointer for
basic_istream::ungetwhen called on a stream with a null
basic_ostream::operator<<(basic_streambuf*)when a null pointer is passed as the argument.
basic_ostream::flush, and every output function on a
unitbufoutput stream, if
ios_base::pwordon failure (e.g. failure to allocate memory)
|eofbit||failbit||badbit|| || || || || ||
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.