名前空間
変種
操作

std::moneypunct<CharT,International>::decimal_point, do_decimal_point

提供: cppreference.com
< cpp‎ | locale‎ | moneypunct
 
 
 
 
ヘッダ <locale> で定義
public:
CharT decimal_point() const;
(1)
protected:
virtual CharT do_decimal_point() const;
(2)
1) public メンバ関数。 最も派生したクラスのメンバ関数 do_decimal_point を呼びます。
2) 書式が小数部を使用する場合 (つまり do_frac_digits() がゼロより大きい場合)、金額入出力で小数点として使用する文字を返します。 一般的な米国ロケールでは、文字 '.' (または L'.') です。

[編集] 戻り値

小数点文字を保持する CharT 型のオブジェクト。

[編集]

#include <iostream>
#include <iomanip>
#include <locale>
 
void show_dpt(const char* locname)
{
    std::locale loc(locname);
    std::cout.imbue(loc);
    std::cout << locname << " decimal point is '"
              << std::use_facet<std::moneypunct<char>>(loc).decimal_point()
              << "' for example: " << std::showbase << std::put_money(123);
    if (std::use_facet<std::moneypunct<char>>(loc).frac_digits() == 0)
        std::cout << " (does not use frac digits) ";
 
    std::cout << '\n';
}
 
int main()
{
    show_dpt("en_US.utf8");
    show_dpt("ja_JP.utf8");
    show_dpt("sv_SE.utf8");
    show_dpt("de_DE.utf8");
 
}

出力:

en_US.utf8 decimal point is '.' for example: $1.23
ja_JP.utf8 decimal point is '.' for example: ¥123 (does not use frac digits)
sv_SE.utf8 decimal point is ',' for example: 1,23 kr
de_DE.utf8 decimal point is ',' for example: 1,23 €

[編集] 関連項目

小数点以下の桁数を提供します
(仮想プロテクテッドメンバ関数) [edit]