名稱空間
變體
操作

std::resetiosflags

來自 cppreference.com
< cpp‎ | io‎ | manip
 
 
 
輸入/輸出操縱器
浮點格式化
整數格式化
布林格式化
欄位寬度和填充控制
其他格式化
空白字元處理
輸出重新整理
(C++20)  

狀態標誌操作
resetiosflags
時間與金錢 I/O
(C++11)
(C++11)
(C++11)
(C++11)
帶引號的操縱器
(C++14)
 
定義於標頭檔案 <iomanip>
/*未指定*/ resetiosflags( std::ios_base::fmtflags mask );

當在表示式 out << resetiosflags(mask)in >> resetiosflags(mask) 中使用時,根據 mask 指定清除流 outin 的所有格式標誌。

目錄

[編輯] 引數

mask - 要清除的標誌的位掩碼

[編輯] 返回值

一個未指定型別的物件,使得

  • out 是型別 std::basic_ostream<CharT, Traits> 的物件,則表示式 out << resetiosflags(mask)
  • in 是型別 std::basic_istream<CharT, Traits> 的物件,則表示式 in >> resetiosflags(mask)

其中函式 f 定義為

void f(std::ios_base& str, std::ios_base::fmtflags mask)
{
    // reset specified flags
    str.setf(ios_base::fmtflags(0), mask);
}

[編輯] 示例

#include <iomanip>
#include <iostream>
#include <sstream>
 
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

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 183 C++98 resetiosflags 只能用於
型別為 std::ostreamstd::istream 的流
可用於任何
字元流

[編輯] 參閱

設定特定格式標誌
(std::ios_base 的公共成員函式) [編輯]
設定指定的 ios_base 標誌
(函式) [編輯]