C++ 概念: UnformattedInputFunction
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
[编辑] 要求
UnformattedInputFunction
流输入功能,执行以下操作:原文:
An
UnformattedInputFunction
is a stream input function that performs the following:- 构造一个对象具有自动存储时间和basic_istream::sentry参数设置为
noskipws
,将执行以下类型的true原文:Constructs an object of type basic_istream::sentry with automatic storage duration and with thenoskipws
argument set to true, which performs the following
- 如果eofbitbadbit上设置的输入流,设置
failbit
,并在此输入流的异常掩码,如果failbit异常启用抛出ios_base::failure.原文:if eofbit or badbit are set on the input stream, sets thefailbit
as well, and if exceptions on failbit are enabled in this input stream's exception mask, throws ios_base::failure. - 刷新了tie()'d输出流(如适用)原文:flushes the tie()'d output stream, if applicable
-
- 检查的状态通过调用
sentry::operator bool()
,这是相当于basic_ios::good哨兵.原文:Checks the status of the sentry by callingsentry::operator bool()
, which is equivalent to basic_ios::good. - 如果返回的哨兵false或哨兵的构造函数抛出一个异常原文:If the sentry returned false or sentry's constructor threw an exception:
- 提取出的字符的数目(gcount的)设置在输入流中为零原文:sets the number of extracted characters (gcount) in the input stream to zero
- 如果函数被调用写数组的
CharT
,写CharT()
(空字符)的数组的第一个位置原文:if the function was called to write to an array ofCharT
, writesCharT()
(the null character) to the first location of the array
-
- 如果返回的哨兵true,进行输入原文:If the sentry returned true, performs the input
- 如果抛出一个异常在输入过程中,设置
badbit
输入流中。中启用此流的异常掩码如果badbit的异常,该异常被重新抛出.原文:if an exception is thrown during input, setsbadbit
in the input stream. If exceptions on badbit are enabled in this stream's exception mask, the exception is also rethrown. - 如果没有异常被抛出在输入过程中,将输入流中提取的字符数(gcount的).原文:If no exception was thrown during input, sets the number of extracted characters (gcount) in the input stream.
-
- 在任何情况下,无论是终止异常或返回,哨兵的析构函数被调用之前离开此功能.原文:In any event, whether terminating by exception or returning, the sentry's destructor is called before leaving this function.
[编辑] 标准库
以下的标准库函数
UnformattedInputFunction
s.原文:
The following standard library functions are
UnformattedInputFunction
s.- std::getline,不同之处在于,它不修改gcount的.原文:std::getline, except that it does not modify gcount.
- basic_istream::operator>>(basic_streambuf*)
- basic_istream::get
- basic_istream::getline
- basic_istream::ignore
- basic_istream::peek
- basic_istream::read
- basic_istream::readsome
- basic_istream::sync,不同之处在于,它不修改gcount的原文:basic_istream::sync, except that it does not modify gcount
- basic_istream::tellg,不同之处在于,它不修改gcount的原文:basic_istream::tellg, except that it does not modify gcount
- basic_istream::seekg,不同之处在于,它首先清除
eofbit
和不修改gcount的原文:basic_istream::seekg, except that it first clearseofbit
and does not modify gcount - std::ws,不同之处在于,它不修改gcount的原文:std::ws, except that it does not modify gcount