std::numpunct<CharT>:: thousands_sep, do_thousands_sep
From cppreference.net
C++
Text processing library
| Localization library | |||||||||||||||||||||||||
| Regular expressions library (C++11) | |||||||||||||||||||||||||
| Formatting library (C++20) | |||||||||||||||||||||||||
| Null-terminated sequence utilities | |||||||||||||||||||||||||
| Byte strings | |||||||||||||||||||||||||
| Multibyte strings | |||||||||||||||||||||||||
| Wide strings | |||||||||||||||||||||||||
| Primitive numeric conversions | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
| Text encoding identifications | |||||||||||||||||||||||||
|
|||||||||||||||||||||||||
Localization library
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::numpunct
| Member functions | ||||
|
numpunct::thousands_sep
numpunct::do_thousands_sep
|
||||
|
ヘッダーで定義
<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]
|
千の区切り文字の各ペア間の桁数を提供する
(仮想保護メンバー関数) |