namespace std {
template <class charT>
class numpunct : public locale::facet;
}
概要
numpunctは、数値の入出力における区切り文字や真偽値の名前といった、句読点に関する情報を提供するロケールファセットである。
num_getとnum_putは、このファセットから取得した情報を使って数値の解析・書式化を行う。
メンバ関数
| 名前 | 説明 |
|---|---|
(constructor) |
コンストラクタ |
decimal_point |
小数点の文字を取得する |
thousands_sep |
桁区切りの文字を取得する |
grouping |
何桁で区切るかの、桁数のシーケンスを取得する |
truename |
trueを表す文字列を取得する |
falsename |
falseを表す文字列を取得する |
静的メンバ変数
| 名前 | 説明 |
|---|---|
static locale::id id; |
このファセットを識別するためのID |
protectedメンバ関数
| 名前 | 説明 |
|---|---|
(destructor) |
デストラクタ |
do_decimal_point |
小数点の文字を取得する |
do_thousands_sep |
桁区切りの文字を取得する |
do_grouping |
何桁で区切るかの、桁数のシーケンスを取得する |
do_truename |
trueを表す文字列を取得する |
do_falsename |
falseを表す文字列を取得する |
メンバ型
| 名前 | 説明 |
|---|---|
char_type |
文字型 charT |
string_type |
文字列型 std::basic_string<charT> |
例
#include <iostream>
#include <locale>
void print_punct(std::locale&& loc)
{
std::cout << loc.name() << std::endl;
const std::numpunct<char>& punct = std::use_facet<std::numpunct<char> >(loc);
// 小数点文字
std::cout << punct.decimal_point() << std::endl;
// 桁区切り文字
std::cout << punct.thousands_sep() << std::endl;
// 何桁で区切るかの、桁数のシーケンス
std::cout << static_cast<int>(punct.grouping()[0]) << std::endl;
std::cout << std::endl;
}
int main()
{
// 日本語
print_punct(std::locale("Japanese"));
// ドイツ語
print_punct(std::locale("German"));
}
出力例
Japanese_Japan.932
.
,
3
German_Germany.1252
,
.
3
バージョン
言語
- C++98