std::moneypunct<CharT,International>:: grouping, do_grouping
From cppreference.net
<
cpp
|
locale
|
moneypunct
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::moneypunct
| Member functions | ||||
|
moneypunct::grouping
moneypunct::do_grouping
|
||||
|
ヘッダーで定義
<locale>
|
||
|
public
:
std:: string grouping ( ) const ; |
(1) | |
|
protected
:
virtual std:: string do_grouping ( ) const ; |
(2) | |
1)
パブリックメンバー関数。最も派生したクラスのメンバー関数
do_grouping
を呼び出す。
2)
通貨出力における桁のグループ化を決定するパターンを返します。その意味は
std::numpunct::do_grouping
と完全に同じです。
戻り値
グループを保持する型
std::string
のオブジェクト。
std::moneypunct
の標準特殊化は、グループ化がないことを示す空の文字列を返します。典型的なグループ化(例:
en_US
ロケール)は
"
\003
"
を返します。
例
このコードを実行
#include <iomanip> #include <iostream> #include <iterator> #include <locale> struct space_out : std::moneypunct<char> { pattern do_pos_format() const { return {value, none, none, none}; } int do_frac_digits() const { return 0; } char_type do_thousands_sep() const { return ' '; } string_type do_grouping() const { return "\002"; } }; int main() { std::cout.imbue(std::locale("en_US.UTF-8")); std::cout << "american locale: " << std::showbase << std::put_money(12345678.0) << '\n'; std::cout.imbue(std::locale(std::cout.getloc(), new space_out)); std::cout << "locale with modified moneypunct: " << std::put_money(12345678.0) << '\n'; }
出力:
american locale: $123,456.78 locale with modified moneypunct: 12 34 56 78
関連項目
|
[virtual]
|
桁区切り文字として使用する文字を提供する
(仮想保護メンバー関数) |
|
[virtual]
|
小数点として使用する文字を提供する
(仮想保護メンバー関数) |