std::moneypunct<CharT,International>::frac_digits, do_frac_digits
From cppreference.com
< cpp | locale | moneypunct
| ヘッダー <locale> で定義 |
||
| public: int frac_digits() const; |
(1) | |
| protected: virtual int do_frac_digits() const; |
(2) | |
1) 公開メンバ関数。最も派生したクラスのメンバ関数
do_frac_digitsを呼び出します。2) 通貨値を表示する際に、小数点以下に表示される桁数を返します。
[編集] 戻り値
小数点以下に表示される桁数。一般的な米国ロケールでは、この値は 2 です。
[編集] 例
このコードを実行
#include <iomanip> #include <iostream> #include <iterator> #include <locale> struct space_out : std::moneypunct<char> { pattern do_pos_format() const { return {value, none, none, none}; } int do_frac_digits() const { return 0; } char_type do_thousands_sep() const { return ' '; } string_type do_grouping() const { return "\002"; } }; int main() { std::cout.imbue(std::locale("en_US.UTF-8")); std::cout << "american locale: " << std::showbase << std::put_money(12345678.0) << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new space_out)); std::cout << "locale with modified moneypunct: " << std::put_money(12345678.0) << '\n'; }
出力
american locale: $123,456.78 locale with modified moneypunct: 12 34 56 78
[編集] 関連項目
| [virtual] |
千単位の区切り文字として使用する文字を提供します (仮想保護メンバ関数) |
| [virtual] |
小数点として使用する文字を提供します (仮想保護メンバ関数) |