std::resetiosflags

来自cppreference.com
< cpp‎ | io‎ | manip
 
 
 
输入/输出操纵符
浮点格式化
整数格式化
布尔格式化
域宽与填充控制
其他格式化
空白符处理
输出冲入
状态标志操纵
resetiosflags
时间与金钱 I/O
(C++11)
(C++11)
(C++11)
(C++11)
带引号操纵符
(C++14)
 
定义于头文件 <iomanip>
/*unspecified*/ resetiosflags( std::ios_base::fmtflags mask );

用于表达式 out << resetiosflags(mask)in >> resetiosflags(mask) 中时,清除流 outinmask 所指定的所有格式标志。

参数

mask - 要清除的标志位掩码

返回值

返回未指定类型的对象,使得若 strstd::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

参阅

设置特定格式标志
(std::ios_base 的公开成员函数)
设置指定的 ios_base 标志
(函数)