std::numpunct
提供: cppreference.com
<tbody>
</tbody>

| ヘッダ <locale> で定義
|
||
template< class CharT > class numpunct; |
||
ファセット std::numpunct は数値の句読点の設定をカプセル化します。 ストリーム入出力操作は数値入力の解析および数値出力の書式化のために std::num_get および std::num_put を通して std::numpunct を使用します。
std::numpunct によってサポートされる数値は後述の書式を持ちます。 digit は fmtflags 引数の値によって指定される基数の設定を表し、 thousands-sep および decimal-point はそれぞれ thousands_sep() および decimal_point() 関数の結果です。 整数値の書式は以下の通りです。
integer ::= [sign] units
sign ::= plusminus
plusminus ::= '+' | '-'
units ::= digits [thousands-sep units]
digits ::= digit [digits]
thousand-sep 間の桁数 (digits の最大サイズ) は grouping() の結果によって指定されます。
浮動小数点値の書式は以下の通りです。
floatval ::= [sign] units [decimal-point [digits]] [e [sign] digits] |
[sign] decimal-point digits [e [sign] digits]
e ::= 'e' | 'E'
継承図
2つのスタンドアロンな (ロケール非依存の) 特殊化が標準ライブラリによって提供されます。
ヘッダ
<locale> で定義 | |
std::numpunct<char>
|
"C" ロケールの設定の同等品を提供します |
std::numpunct<wchar_t>
|
"C" ロケールの設定のワイド文字の同等品を提供します |
さらに、 C++ のプログラム内で構築されたすべてのロケールオブジェクトは、これらの特殊化の独自の (ロケール固有の) バージョンを実装します。
メンバ型
| メンバ型 | 定義 |
char_type
|
charT
|
string_type
|
std::basic_string<charT>
|
メンバ関数
| 新しい numpunct ファセットを構築します (パブリックメンバ関数) | |
| numpunct ファセットを破棄します (プロテクテッドメンバ関数) | |
do_decimal_point を呼びます (パブリックメンバ関数) | |
do_thousands_sep を呼びます (パブリックメンバ関数) | |
do_grouping を呼びます (パブリックメンバ関数) | |
do_truename または do_falsename を呼びます (パブリックメンバ関数) |
プロテクテッドメンバ関数
[仮想] |
小数点として使用する文字を提供します (仮想プロテクテッドメンバ関数) |
[仮想] |
桁区切りとして使用される文字を提供します (仮想プロテクテッドメンバ関数) |
[仮想] |
それぞれの桁区切り文字間の桁数を提供します (仮想プロテクテッドメンバ関数) |
ブーリアン true および false の名前として使用する文字列を提供します (仮想プロテクテッドメンバ関数) |
メンバオブジェクト
static std::locale::id id |
ロケールの id (パブリックメンバオブジェクト) |
例
以下の例は true と false の文字列表現を変更します。
Run this code
#include <iostream>
#include <locale>
struct french_bool : std::numpunct<char> {
string_type do_truename() const { return "vrai"; }
string_type do_falsename() const { return "faux"; }
};
int main()
{
std::cout << "default locale: "
<< std::boolalpha << true << ", " << false << '\n';
std::cout.imbue(std::locale(std::cout.getloc(), new french_bool));
std::cout << "locale with modified numpunct: "
<< std::boolalpha << true << ", " << false << '\n';
}
出力:
default locale: true, false
locale with modified numpunct: vrai, faux
関連項目
| 名前付きロケールに対する numpunct ファセットを作成します (クラステンプレート) |