std::resetiosflags
Defined in header <iomanip> | | |
---|---|---|
/*unspecified*/ resetiosflags( std::ios_base::fmtflags mask ); | | |
在表达式中使用时out << resetiosflags(mask)
或in >> resetiosflags(mask)
,清除流的所有格式标志。out
或in
由mask
...
参数
mask | - | bitmask of the flags to clear |
---|
返回值
返回未指定类型的对象,以便在str
类型的输出流的名称。std::basic_ostream<CharT, Traits>
或std::basic_istream<CharT, Traits>
,然后表达str << resetiosflags(mask)
或str >> resetiosflags(mask)
行为就像执行了以下代码:
str.setf(std::ios_base::fmtflags(0), mask);
例
二次
#include <sstream>
#include <iostream>
#include <iomanip>
int main()
{
std::istringstream in("10 010 10 010 10 010");
int n1, n2;
in >> std::oct >> n1 >> n2;
std::cout << "Parsing \"10 010\" with std::oct gives: " << n1 << ' ' << n2 << '\n';
in >> std::dec >> n1 >> n2;
std::cout << "Parsing \"10 010\" with std::dec gives: " << n1 << ' ' << n2 << '\n';
in >> std::resetiosflags(std::ios_base::basefield) >> n1 >> n2;
std::cout << "Parsing \"10 010\" with autodetect gives: " << n1 << ' ' << n2 << '\n';
}
二次
产出:
二次
Parsing "10 010" with std::oct gives: 8 8
Parsing "10 010" with std::dec gives: 10 10
Parsing "10 010" with autodetect gives: 10 8
二次
另见
setf | sets specific format flag (public member function of std::ios_base) |
---|---|
setiosflags | sets the specified ios_base flags (function) |
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com