std::ios_base::iostate
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
typedef /*implementation defined*/ iostate; |
||
static constexpr iostate goodbit = 0; |
||
static constexpr iostate badbit = /*implementation defined*/ static constexpr iostate failbit = /*implementation defined*/ |
||
指定流的状态标志。这是一个
BitmaskType
,下面的常量定义 原文:
Specifies stream state flags. It is a
BitmaskType
, the following constants are defined: 常数
|
Explanation |
goodbit | 没有错误
|
badbit | 无法收回的流错误
|
failbit | 输入/输出操作失败,(格式化或提取错误)
原文: input/output operation failed (formatting or extraction error) |
eofbit | 相关的输入序列中已达到文件结束
原文: associated input sequence has reached end-of-file |
目录 |
[编辑] eofbit
以下标准库函数:eofbit设置
原文:
The eofbit is set by the following standard library functions:
- 如果它完成的字符串输入功能std::getline到达流的末尾,而不是到达指定的终止字符.原文:The string input function std::getline if it completes by reaching the end of the stream, as opposed to reaching the specified terminating character.
- 数字输入过载时遇到的basic_istream::operator>>流的末尾,如果读取一个字符,第2阶段num_get::get处理。
failbit
根据解析状态,可能会或可能不会被设置在相同的时间:例如,int n; istringstream buf("1"); buf >> n;集eofbit
,但不failbit
:整数1成功解析并存储在n
。另一方面,bool b; istringstream buf("tr"); buf >> boolalpha >> b;设置eofbit
和failbit
:没有足够的字符来完成解析的布尔true.原文:The numeric input overloads of basic_istream::operator>> if the end of the stream was encountered while reading the next character, on Stage 2 of num_get::get processing. Depending on the parsing state,failbit
may or may not be set at the same time: for example, int n; istringstream buf("1"); buf >> n; setseofbit
, but notfailbit
: the integer 1 was successfully parsed and stored inn
. On the other hand, bool b; istringstream buf("tr"); buf >> boolalpha >> b; sets botheofbit
andfailbit
: there was not enough characters to complete the parsing of the boolean true. - 的字符提取重载operator>>std::basic_istream,如果最终的数据流要被提取的字符的数目的限制(如有的话)之前到达.原文:The character extraction overloads of 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.
- I / O的std::get_time机械手和std::time_get解析函数:time_get::get,time_get::get_time,time_get::get_date等,如果流的末尾,达到之前的最后一个字符需要分析处理预期的日期/时间值.原文:The std::get_time I/O manipulator and any of the std::time_get parsing functions: time_get::get, time_get::get_time, 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.
- I / Ostd::get_money机械手和money_get::get功能,如果到达流的末尾,是处理前的最后一个字符需要解析的预期货币价值.原文:The std::get_money I/O manipulator and money_get::get function, if the end of the stream is reached before the last character needed to parse the expected monetary value was processed.
- basic_istream::sentry的构造函数,在开始执行的每一个格式化的输入功能:除非
skipws
位中unset(例如发出std::noskipws),,放哨的读取和丢弃前导空格字符。如果输入流的结束达到在此操作过程中,都eofbit
和failbit
被设置,并没有输入发生.原文:The basic_istream::sentry constructor, executed at the beginning of every formatted input function: unless theskipws
bit 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, botheofbit
andfailbit
are set, and no input takes place. - I / O机械手std::ws,如果到达流的末尾,而消耗的空白(但是,不同的是格式化的输入哨兵,它不设置
failbit
在这种情况下)原文:The I/O manipulator std::ws, if it reaches the end of the stream while consuming whitespace (but, unlike the formatted input sentry, it does not setfailbit
in this case) - 未格式化的输入功能basic_istream::read,basic_istream::get,basic_istream::getline,当到达流的末尾,.原文:The unformatted input functions basic_istream::read, basic_istream::get, and basic_istream::getline, when reaching the end of the stream.
- 丢弃输入功能basic_istream::ignore,当到达流的末尾,前到达指定的分隔符.原文:The discard input function basic_istream::ignore, when reaching the end of the stream before reaching the specified delimiter character.
以下功能清除
eofbit
的副作用原文:
The following functions clear
eofbit
as a side-effect:[编辑] failbit
的的failbit设定以下标准库函数:
原文:
The failbit is set by the following standard library functions:
本章尚未完成 |
[编辑] badbit
以下标准库函数:badbit设置
原文:
The badbit is set by the following standard library functions:
本章尚未完成 原因:move from ios_base::bad and expand |
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
ios_base::iostate flags | basic_ios accessors | |||||||
eofbit | failbit | badbit | good() | fail() | bad() | eof() | operator bool() | operator!() |
false | false | false | true | false | false | false | true | false |
false | false | true | false | true | true | false | false | true |
false | true | false | false | true | false | false | false | true |
false | true | true | false | true | true | false | false | true |
true | false | false | false | false | false | true | true | false |
true | false | true | false | true | true | true | false | true |
true | true | false | false | true | false | true | false | true |
true | true | true | false | true | true | true | false | true |