Namespaces
Variants

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

From cppreference.net
ヘッダーで定義 <locale>
public :
CharT decimal_point ( ) const ;
(1)
protected :
virtual CharT do_decimal_point ( ) const ;
(2)
1) パブリックメンバー関数。最も派生したクラスのメンバー関数 do_decimal_point を呼び出す。
2) 通貨I/Oで分数を使用する場合(つまり、 do_frac_digits() がゼロより大きい場合)、小数点区切り文字として使用する文字を返します。典型的な米国ロケールでは、これは文字 '.' (または L '.' )です。

戻り値

CharT 型のオブジェクトは、小数点文字を保持します。

#include <iomanip>
#include <iostream>
#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 €

関連項目

小数点以下に表示する桁数を提供する
(仮想 protected メンバー関数)