std::moneypunct_byname
STD:货币量[医]名名
Defined in header | | |
---|---|---|
template< class CharT, bool Intl = false > class moneypunct_byname : public std::moneypunct<CharT, Intl>; | | |
std::moneypunct_byname
是std::moneypunct
facet,它封装在构造时指定的区域设置的货币格式首选项。
标准库提供了两个专门化。
在标头中定义<locale>
*。
STD:货币量[医]名称<char,intl>特定于地区的std::窄字符I/O的货币性面
STD:货币量[医]名<wchar[医]特定于地区的STD::宽字符I/O的货币性面
成员类型
Member type | Definition |
---|---|
pattern | std::money_base::pattern |
string_type | std::basic_string<CharT> |
成员函数
(constructor) | constructs a new moneypunct_byname facet (public member function) |
---|---|
(destructor) | destroys a moneypunct_byname facet (protected member function) |
STD:货币量[医]名称::货币区[医]名名
explicit moneypunct_byname( const char* name, std::size_t refs = 0 | | |
---|---|---|
explicit moneypunct_byname( const std::string& name, std::size_t refs = 0 | | (since C++11) |
构造一个新的std::moneypunct_byname
区域设置的方面name
...
refs
用于资源管理:如果refs == 0
时,该实现破坏了面。std::locale
保存它的对象被销毁。否则,该对象不会被销毁。
参数
name | - | the name of the locale |
---|---|---|
refs | - | the number of references that link to the facet |
STD:货币量[医]名称::~货币化[医]名名
protected: ~moneypunct_byname( | | |
---|
摧毁了这个面。
继承自STD:货币量
成员类型
Member type | Definition |
---|---|
char_type | CharT |
string_type | std::basic_string<CharT> |
成员函数
decimal_point | invokes do_decimal_point (public member function of std::moneypunct) |
---|---|
thousands_sep | invokes do_thousands_sep (public member function of std::moneypunct) |
grouping | invokes do_grouping (public member function of std::moneypunct) |
curr_symbol | invokes do_curr_symbol (public member function of std::moneypunct) |
positive_signnegative_sign | invokes do_positive_sign or do_negative_sign (public member function of std::moneypunct) |
frac_digits | invokes do_frac_digits (public member function of std::moneypunct) |
pos_formatneg_format | invokes do_pos_format/do_neg_format (public member function of std::moneypunct) |
受保护成员函数
do_decimal_point virtual | provides the character to use as decimal point (virtual protected member function of std::moneypunct) |
---|---|
do_thousands_sep virtual | provides the character to use as thousands separator (virtual protected member function of std::moneypunct) |
do_grouping virtual | provides the numbers of digits between each pair of thousands separators (virtual protected member function of std::moneypunct) |
do_curr_symbol virtual | provides the string to use as the currency identifier (virtual protected member function of std::moneypunct) |
do_positive_signdo_negative_sign virtual | provides the string to indicate a positive or negative value (virtual protected member function of std::moneypunct) |
do_frac_digits virtual | provides the number of digits to display after the decimal point (virtual protected member function of std::moneypunct) |
do_pos_formatdo_neg_format virtual | provides the formatting pattern for currency values (virtual protected member function of std::moneypunct) |
成员常数
Member | Definition |
---|---|
const bool intl (static) | International |
成员对象
static std::locale::id id | id of the locale (public member object) |
---|
继承自STD:钱[医]底座
Member type | Definition |
---|---|
enum part { none, space, symbol, sign, value }; | unscoped enumeration type |
struct pattern { char field4; }; | the monetary format type |
Enumeration constant | Definition |
---|---|
none | whitespace is permitted but not required except in the last position, where whitespace is not permitted |
space | one or more whitespace characters are required |
symbol | the sequence of characters returned by moneypunct::curr_symbol is required |
sign | the first of the characters returned by moneypunct::positive_sign or moneypunct::negative_sign is required |
value | the absolute numeric monetary value is required |
例
此示例演示如何应用另一种语言的货币格式规则,而不更改其余的区域设置。
二次
#include <iostream>
#include <iomanip>
#include <locale>
int main()
{
long double mon = 1234567;
std::locale::global(std::locale("en_US.utf8")
std::wcout.imbue(std::locale()
std::wcout << L"american locale : " << std::showbase
<< std::put_money(mon) << '\n';
std::wcout.imbue(std::locale(std::wcout.getloc(),
new std::moneypunct_byname<wchar_t>("ru_RU.utf8"))
std::wcout << L"american locale with russian moneypunct: "
<< std::put_money(mon) << '\n';
}
二次
产出:
二次
american locale : $12,345.67
american locale with russian moneypunct: 12 345.67 руб
二次
另见
moneypunct | defines monetary formatting parameters used by std::money_get and std::money_put (class template) |
---|
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。