std::numpunct<CharT>::thousands_sep, do_thousands_sep
From cppreference.com
| ヘッダー <locale> で定義 |
||
| public: char_type thousands_sep() const; |
(1) | |
| protected: virtual char_type do_thousands_sep() const; |
(2) | |
1) 公開メンバ関数。最も派生したクラスのメンバ関数
do_thousands_sepを呼び出します。2) 整数や浮動小数点値の整数部分を解析またはフォーマットする際に、桁区切り文字として使用される文字を返します。
目次 |
[編集] 戻り値
千単位の区切り文字として使用されるchar_type型のオブジェクト。std::numpunctの標準特殊化は、',' および L',' を返します。
[編集] 例
このコードを実行
#include <iostream> #include <locale> struct space_out : std::numpunct<char> { char do_thousands_sep() const { return ' '; } // separate with spaces std::string do_grouping() const { return "\1"; } // groups of 1 digit }; int main() { std::cout << "default locale: " << 12345678 << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new space_out)); std::cout << "locale with modified numpunct: " << 12345678 << '\n'; }
出力
default locale: 12345678 locale with modified numpunct: 1 2 3 4 5 6 7 8
[編集] 不具合報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 20 | C++98 | 戻り値の型がstring_typeでした。 |
char_typeに変更されました。 |
[編集] 関連項目
| [virtual] |
各桁区切り記号のペア間の桁数を提供します。 (仮想保護メンバ関数) |