std::ws
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <istream> 中定义
|
||
template< class CharT, class Traits > std::basic_istream<CharT,Traits>& ws( std::basic_istream<CharT, Traits>& is ); |
||
丢弃领导从输入流中的空白.....
原文:
Discards leading whitespace from an input stream.
作为
UnformattedInputFunction
的行为,但没有被修改,is.gcount()。在建设和检查岗哨对象的,提取的字符从流中丢弃它们,直到发生以下任何一个条件原文:
Behaves as an
UnformattedInputFunction
, except that is.gcount() is not modified. After constructing and checking the sentry object, extracts characters from the stream and discards them until any one of the following conditions occurs:- 结束的文件的情况发生在输入序列中(在这种情况下,该函数调用setstate(eofbit),但不
failbit
原文:end of file condition occurs in the input sequence (in which case the function calls setstate(eofbit) but does not setfailbit
.
- 输入序列中的下一个可用的字符
c
非空字符所确定的std::isspace(c, is.getloc())。非空白字符是不提取原文:the next available characterc
in the input sequence is not whitespace as determined by std::isspace(c, is.getloc()). The non-whitespace character is not extracted.
这是一个I / O输入机械手,它可被称为与表达,如in << std::ws任何类型的
in
std::basic_istream.原文:
This is an input-only I/O manipulator, it may be called with an expression such as in << std::ws for any
in
of type std::basic_istream.目录 |
[编辑] 参数
is | - | 参考输入流
|
[编辑] 返回值
is
的流提取后的连续的空白原文:
is
(reference to the stream after extraction of consecutive whitespace)[编辑] 示例
#include <iostream> #include <sstream> int main() { std::istringstream s(" this is a test"); std::string line; s >> std::ws; getline(s, line); std::cout << "ws + getline returns: \"" << line << "\"\n"; }
输出:
ws + getline returns: "this is a test"
[编辑] 另请参阅
提取物和丢弃给定字符的字符,直到被发现 原文: extracts and discards characters until the given character is found (公共成员函数of std::basic_istream )
|