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 | |||||||||||||||||||||||||
|
|
Defined in header <locale> | ||
template<class CharT,bool Intl=false> class moneypunct_byname:publicstd::moneypunct<CharT, Intl>; | ||
std::moneypunct_byname
is astd::moneypunct facet which encapsulates monetary formatting preferences of a locale specified at its construction.
Contents |
The standard library is guaranteed to provide every specialization that satisfies the following type requirements:
CharT
is one ofchar andwchar_t, andIntl
is a possible specialization on abool parameter.Type | Definition |
pattern | std::money_base::pattern |
string_type | std::basic_string<CharT> |
(constructor) | constructs a newmoneypunct_byname facet(public member function)[edit] |
(destructor) | destroys amoneypunct_byname facet(protected member function)[edit] |
explicit moneypunct_byname(constchar* name,std::size_t refs=0); | ||
explicit moneypunct_byname(conststd::string& name,std::size_t refs=0); | (since C++11) | |
Constructs a newstd::moneypunct_byname
facet for a locale withname.
refs is used for resource management: ifrefs==0, the implementation destroys the facet, when the laststd::locale object holding it is destroyed. Otherwise, the object is not destroyed.
name | - | the name of the locale |
refs | - | the number of references that link to the facet |
protected: ~moneypunct_byname(); | ||
Destroys the facet.
Type | Definition |
char_type | CharT |
string_type | std::basic_string<CharT> |
Member | Description |
std::locale::idid [static] | the identifier of thefacet |
constboolintl [static] | International |
invokesdo_decimal_point (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_thousands_sep (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_grouping (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_curr_symbol (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_positive_sign ordo_negative_sign (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_frac_digits (public member function of std::moneypunct<CharT,International> )[edit] | |
invokesdo_pos_format /do_neg_format (public member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the character to use as decimal point (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the character to use as thousands separator (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the numbers of digits between each pair of thousands separators (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the string to use as the currency identifier (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the string to indicate a positive or negative value (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the number of digits to display after the decimal point (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
[virtual] | provides the formatting pattern for currency values (virtual protected member function of std::moneypunct<CharT,International> )[edit] |
Type | Definition |
enum part{ none, space, symbol, sign, value}; | unscoped enumeration type |
struct pattern{char field[4];}; | the monetary format type |
Enumeration constant | Description |
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 bystd::moneypunct::curr_symbol is required |
sign | the first of the characters returned bystd::moneypunct::positive_sign orstd::moneypunct::negative_sign is required |
value | the absolute numeric monetary value is required |
This example demonstrates how to apply monetary formatting rules of another language without changing the rest of the locale.
#include <iomanip>#include <iostream>#include <locale> int main(){longdouble 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';}
Output:
american locale: $12,345.67american locale with russian moneypunct: 12 345.67 руб
defines monetary formatting parameters used bystd::money_get andstd::money_put (class template)[edit] |