Namespaces
Variants

std::ios_base:: fmtflags

From ja.cppreference.net
typedef /*実装定義*/ fmtflags ;
static constexpr fmtflags dec = /*実装定義*/

static constexpr fmtflags oct = /*実装定義*/
static constexpr fmtflags hex = /*実装定義*/

static constexpr fmtflags basefield = dec | oct | hex ;
static constexpr fmtflags left = /*実装定義*/

static constexpr fmtflags right = /*実装定義*/
static constexpr fmtflags internal = /*実装定義*/

static constexpr fmtflags adjustfield = left | right | internal ;
static constexpr fmtflags scientific = /*実装定義*/

static constexpr fmtflags fixed = /*実装定義*/

static constexpr fmtflags floatfield = scientific | fixed ;
static constexpr fmtflags boolalpha = /*実装定義*/

static constexpr fmtflags showbase = /*実装定義*/
static constexpr fmtflags showpoint = /*実装定義*/
static constexpr fmtflags showpos = /*実装定義*/
static constexpr fmtflags skipws = /*実装定義*/
static constexpr fmtflags unitbuf = /*実装定義*/

static constexpr fmtflags uppercase = /*実装定義*/

利用可能なフォーマットフラグを指定します。これは BitmaskType です。以下の定数が定義されています:

定数 説明
dec 整数I/Oに10進基数を使用: std::dec を参照
oct 整数I/Oに8進基数を使用: std::oct を参照
hex 整数I/Oに16進基数を使用: std::hex を参照
basefield dec | oct | hex . マスキング操作に有用
left 左揃え(右側に埋め文字を追加): std::left を参照
right 右揃え(左側に埋め文字を追加): std::right を参照
internal 内部揃え(内部指定点に埋め文字を追加): std::internal を参照
adjustfield left | right | internal . マスキング操作に有用
scientific 浮動小数点型を指数表記で生成、 fixed と組み合わせた場合は16進表記: std::scientific を参照
fixed 浮動小数点型を固定小数点表記で生成、 scientific と組み合わせた場合は16進表記: std::fixed を参照
floatfield scientific | fixed . マスキング操作に有用
boolalpha bool 型を英数字形式で挿入・抽出: std::boolalpha を参照
showbase 整数出力で数値基数を示す接頭辞を生成、通貨I/Oで通貨指示子を要求: std::showbase を参照
showpoint 浮動小数点数出力で小数点文字を無条件に生成: std::showpoint を参照
showpos 非負数値出力で + 文字を生成: std::showpos を参照
skipws 特定の入力操作前に先頭の空白をスキップ: std::skipws を参照
unitbuf 各出力操作後に出力をフラッシュ: std::unitbuf を参照
uppercase 特定の出力操作で特定の小文字を大文字に置換: std::uppercase を参照

例

以下の例は、同じ結果を出力するいくつかの異なる方法を示しています。

#include <iostream>
int main()
{
    const int num = 150;
    // using fmtflags as class member constants:
    std::cout.setf(std::ios_base::hex, std::ios_base::basefield);
    std::cout.setf(std::ios_base::showbase);
    std::cout << num << '\n';
    // using fmtflags as inherited class member constants:
    std::cout.setf (std::ios::hex, std::ios::basefield);
    std::cout.setf (std::ios::showbase);
    std::cout << num << '\n';
    // using fmtflags as object member constants:
    std::cout.setf(std::cout.hex, std::cout.basefield);
    std::cout.setf(std::cout.showbase);
    std::cout << num << '\n';
    // using fmtflags as a type:
    std::ios_base::fmtflags ff;
    ff = std::cout.flags();
    ff &= ~std::cout.basefield;   // unset basefield bits
    ff |= std::cout.hex;          // set hex
    ff |= std::cout.showbase;     // set showbase
    std::cout.flags(ff);
    std::cout << num << '\n';
    // not using fmtflags, but using manipulators:
    std::cout << std::hex << std::showbase << num << '\n';
}

出力:

0x96
0x96
0x96
0x96
0x96

関連項目

フォーマットフラグを管理する
(public member function)
特定のフォーマットフラグを設定する
(public member function)
特定のフォーマットフラグをクリアする
(public member function)
整数I/Oで使用される基数を変更する
(function)
フィル文字を変更する
(function template)
浮動小数点I/Oで使用されるフォーマットを変更する
(function)
数値の基数を示す接頭辞を使用するかどうかを制御する
(function)
ブール値のテキスト表現と数値表現を切り替える
(function)
非負数に + 符号を使用するかどうかを制御する
(function)
浮動小数点表現で常に小数点を含めるかどうかを制御する
(function)
各操作後に出力をフラッシュするかどうかを制御する
(function)
入力時に先頭の空白をスキップするかどうかを制御する
(function)
一部の出力フォーマットで大文字を使用するかどうかを制御する
(function)