在线文档教程
C++
本土化 | Localizations

std::moneypunct_byname

STD:货币量[医]名名

Defined in header
template< class CharT, bool Intl = false > class moneypunct_byname : public std::moneypunct<CharT, Intl>;

std::moneypunct_bynamestd::moneypunctfacet,它封装在构造时指定的区域设置的货币格式首选项。

标准库提供了两个专门化。

在标头中定义<locale>

*。

STD:货币量[医]名称<char,intl>特定于地区的std::窄字符I/O的货币性面

STD:货币量[医]名<wchar[医]特定于地区的STD::宽字符I/O的货币性面

成员类型

Member typeDefinition
patternstd::money_base::pattern
string_typestd::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 typeDefinition
char_typeCharT
string_typestd::basic_string<CharT>

成员函数

decimal_pointinvokes do_decimal_point (public member function of std::moneypunct)
thousands_sepinvokes do_thousands_sep (public member function of std::moneypunct)
groupinginvokes do_grouping (public member function of std::moneypunct)
curr_symbolinvokes do_curr_symbol (public member function of std::moneypunct)
positive_signnegative_signinvokes do_positive_sign or do_negative_sign (public member function of std::moneypunct)
frac_digitsinvokes do_frac_digits (public member function of std::moneypunct)
pos_formatneg_formatinvokes do_pos_format/do_neg_format (public member function of std::moneypunct)

受保护成员函数

do_decimal_point virtualprovides the character to use as decimal point (virtual protected member function of std::moneypunct)
do_thousands_sep virtualprovides the character to use as thousands separator (virtual protected member function of std::moneypunct)
do_grouping virtualprovides the numbers of digits between each pair of thousands separators (virtual protected member function of std::moneypunct)
do_curr_symbol virtualprovides the string to use as the currency identifier (virtual protected member function of std::moneypunct)
do_positive_signdo_negative_sign virtualprovides the string to indicate a positive or negative value (virtual protected member function of std::moneypunct)
do_frac_digits virtualprovides the number of digits to display after the decimal point (virtual protected member function of std::moneypunct)
do_pos_formatdo_neg_format virtualprovides the formatting pattern for currency values (virtual protected member function of std::moneypunct)

成员常数

MemberDefinition
const bool intl (static)International

成员对象

static std::locale::id idid of the locale (public member object)

继承自STD:钱[医]底座

Member typeDefinition
enum part { none, space, symbol, sign, value };unscoped enumeration type
struct pattern { char field4; };the monetary format type

Enumeration constantDefinition
nonewhitespace is permitted but not required except in the last position, where whitespace is not permitted
spaceone or more whitespace characters are required
symbolthe sequence of characters returned by moneypunct::curr_symbol is required
signthe first of the characters returned by moneypunct::positive_sign or moneypunct::negative_sign is required
valuethe 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 руб

二次

另见

moneypunctdefines monetary formatting parameters used by std::money_get and std::money_put (class template)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/locale/货币化[医]名名