std:: skipws, std:: noskipws
|
定义于头文件
<ios>
|
||
|
std::
ios_base
&
skipws
(
std::
ios_base
&
str
)
;
|
(1) | |
|
std::
ios_base
&
noskipws
(
std::
ios_base
&
str
)
;
|
(2) | |
启用或禁用格式化输入函数跳过前导空白字符的功能(默认启用)。对输出无影响。
空白符的跳过操作由 std::basic_istream::sentry 的构造函数执行,该函数会读取并丢弃被流所植入区域设置的 std::ctype 平面分类为空白符的字符。
这是一个I/O操纵器,可以通过形如
out
<<
std
::
noskipws
的表达式调用(适用于任何
out
类型的
std::basic_ostream
),或通过形如
in
>>
std
::
noskipws
的表达式调用(适用于任何
in
类型的
std::basic_istream
)。
目录 |
参数
| str | - | I/O 流的引用 |
返回值
str (指向经过操作后的流的引用)。
示例
#include <iostream> #include <sstream> int main() { char c1, c2, c3; std::istringstream("a b c") >> c1 >> c2 >> c3; std::cout << "Default behavior:" " c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n'; std::istringstream("a b c") >> std::noskipws >> c1 >> c2 >> c3; std::cout << "noskipws behavior:" " c1 = " << c1 << " c2 = " << c2 << " c3 = " << c3 << '\n'; }
输出:
Default behavior: c1 = a c2 = b c3 = c noskipws behavior: c1 = a c2 = c3 = b
参见
|
清除指定的 ios_base 标志
(函数) |
|
设置指定的
ios_base
标志
(函数) |
|
|
消耗空白字符
(函数模板) |