名前空間
変種
操作

std::moneypunct_byname

From cppreference.com
< cpp‎ | locale
 
 
 
 
ヘッダー <locale> で定義
template< class CharT, bool Intl = false >
class moneypunct_byname : public std::moneypunct<CharT, Intl>;

std::moneypunct_byname は、構築時に指定されたロケールの通貨フォーマット設定をカプセル化する std::moneypunct ファセットです。

目次

[編集] 特殊化

標準ライブラリは、以下の型要件を満たすすべての特殊化を提供することが保証されています。

  • CharTcharwchar_tのいずれかであり、
  • Intl は、bool パラメータに対する特殊化の可能性があります。

[編集] ネストされた型

定義
パターン std::money_base::pattern
string_type std::basic_string<CharT>

[編集] メンバ関数

(コンストラクタ)
新しい moneypunct_byname ファセットを構築します。
(public member function) [編集]
(デストラクタ)
moneypunct_byname ファセットを破棄します。
(protected member function) [編集]

std::moneypunct_byname::moneypunct_byname

explicit moneypunct_byname( const char* name, std::size_t refs = 0 );
explicit moneypunct_byname( const std::string& name, std::size_t refs = 0 );
(C++11以降)

name で指定されたロケール用の新しい std::moneypunct_byname ファセットを構築します。

refs はリソース管理に使用されます。 refs == 0 の場合、それを持つ最後の std::locale オブジェクトが破棄されるときに、実装はファセットを破棄します。それ以外の場合、オブジェクトは破棄されません。

パラメータ

name - ロケールの名前
refs - ファセットを参照する参照の数

std::moneypunct_byname::~moneypunct_byname

protected:
~moneypunct_byname();

ファセットを破棄します。

std::moneypunct から継承

ネストされた型

定義
char_type CharT
string_type std::basic_string<CharT>

データメンバ

メンバ 説明
std::locale::id id [static] ファセットの識別子
const bool intl [static] 国際的

メンバ関数

do_decimal_point を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_thousands_sep を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_grouping を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_curr_symbol を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_positive_sign または do_negative_sign を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_frac_digits を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]
do_pos_format/do_neg_format を呼び出します。
(std::moneypunct<CharT,International> の public メンバ関数) [編集]

Protected member functions

小数点として使用する文字を提供します
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
千単位の区切り文字として使用する文字を提供します
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
[virtual]
各桁区切り記号のペア間の桁数を提供します。
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
通貨識別子として使用する文字列を提供します。
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
正または負の値を示す文字列を提供します。
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
小数点以下の桁数を提供します。
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]
通貨値の書式設定パターンを提供します。
(std::moneypunct<CharT,International> の virtual protected メンバ関数) [編集]

std::money_base から継承

ネストされた型

定義
enum part { none, space, symbol, sign, value }; スコープなし列挙型
struct pattern { char field[4]; }; 通貨書式設定の型
列挙定数 説明
なし 空白文字は許可されますが、最後の位置を除き、必須ではありません。最後の位置では空白文字は許可されません。
スペース 1 つ以上の空白文字が必要です。
記号 std::moneypunct::curr_symbol によって返される文字シーケンスが必要です。
符号 std::moneypunct::positive_sign または std::moneypunct::negative_sign によって返される文字の最初の文字が必要です。
value 絶対数値の通貨値が必要です。

[編集]

この例は、ロケールの他の部分を変更せずに、別の言語の通貨フォーマットルールを適用する方法を示しています。

#include <iomanip>
#include <iostream>
#include <locale>
 
int main()
{
    long double mon = 1234567;
    std::locale::global(std::locale("en_US.utf8"));
    std::wcout.imbue(std::locale());
    std::wcout << L"american locale: " << std::showbase
               << std::put_money(mon) << '\n';
    std::wcout.imbue(std::locale(std::wcout.getloc(),
                                 new std::moneypunct_byname<wchar_t>("ru_RU.utf8")));
    std::wcout << L"american locale with russian moneypunct: "
               << std::put_money(mon) << '\n';
}

出力

american locale: $12,345.67
american locale with russian moneypunct: 12 345.67 руб

[編集] 関連項目

std::money_getstd::money_put で使用される通貨書式設定パラメータを定義する
(クラステンプレート) [編集]
English 日本語 中文(简体) 中文(繁體)