Namespaces
Variants

std:: resetiosflags

From cppreference.net
< cpp ‎ | io ‎ | manip
Input/output manipulators
Floating-point formatting
Integer formatting
Boolean formatting
Field width and fill control
Other formatting
Whitespace processing
Output flushing
Status flags manipulation
resetiosflags
Time and money I/O
(C++11)
(C++11)
(C++11)
(C++11)
Quoted manipulator
(C++14)
ヘッダーで定義 <iomanip>
/*unspecified*/ resetiosflags ( std:: ios_base :: fmtflags mask ) ;

式内で out << resetiosflags ( mask ) または in >> resetiosflags ( mask ) が使用されると、 mask で指定されたストリーム out または in のすべての書式フラグをクリアします。

目次

パラメータ

mask - クリアするフラグのビットマスク

戻り値

未指定の型のオブジェクトであり、以下の条件を満たすもの

  • out が型 std:: basic_ostream < CharT, Traits > のオブジェクトである場合、式 out << resetiosflags ( mask )
    • 型は std:: basic_ostream < CharT, Traits > &
    • 値は out
    • f ( out, mask ) を呼び出したかのように振る舞う
  • in が型 std:: basic_istream < CharT, Traits > のオブジェクトである場合、式 in >> resetiosflags ( mask )
    • 型は std:: basic_istream < CharT, Traits > &
    • 値は in
    • f ( in, mask ) を呼び出したかのように振る舞う

関数 f が以下のように定義されている場合:

void f(std::ios_base& str, std::ios_base::fmtflags mask)
{
    // 指定されたフラグをリセット
    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++規格に対して遡及的に適用されました。

DR Applied to Behavior as published Correct behavior
LWG 183 C++98 resetiosflags
型が std::ostream または std::istream のストリームでのみ使用可能
任意の文字ストリーム
で使用可能

関連項目

特定のフォーマットフラグを設定
( std::ios_base の公開メンバ関数)
指定された ios_base フラグを設定
(関数)