char_type decimal_point() const; // (1) C++98
概要
小数点の文字を取得する。
戻り値
do_decimal_point()の呼び出し結果を返す。
例
#include <iostream>
#include <locale>
#include <stdexcept>
int main()
{
for (const char* name : {"C", "en_US.UTF-8", "ja_JP.UTF-8", "de_DE.UTF-8"}) {
try {
std::locale loc{name};
const auto& np = std::use_facet<std::numpunct<char>>(loc);
std::cout << name << " : [" << np.decimal_point() << "]" << std::endl;
}
catch (const std::runtime_error&) {
// 指定した名前のロケールが利用できない場合
std::cout << name << " : not available" << std::endl;
}
}
}
出力例
C : [.]
en_US.UTF-8 : [.]
ja_JP.UTF-8 : [.]
de_DE.UTF-8 : [,]
- ドイツのロケールでは小数点にカンマが使われる
- 妥当なロケール名は処理系定義である。指定した名前のロケールが利用できない場合、
std::localeのコンストラクタはstd::runtime_errorを送出し、上記の例ではnot availableが出力される
バージョン
言語
- C++98