std::moneypunct_byname
From cppreference.com
Defined in header <locale>
|
||
template< class charT, bool Intl = false > class moneypunct_byname : public std::moneypunct<charT, Intl>; |
||
std::moneypunct_byname is a std::moneypunct facet which encapsulates monetary formatting preferences of a locale specified at its construction.
Two specializations are provided by the standard library
Defined in header <locale>
| |
std::moneypunct_byname<char, Intl> | locale-specific std::moneypunct facet for narrow character I/O |
std::moneypunct_byname<wchar_t, Intl> | locale-specific std::moneypunct facet for wide character I/O |
Contents |
[edit] Member types
Member type | Definition |
pattern | std::money_base::pattern |
string_type | std::basic_string<charT> |
[edit] Member functions
constructs a new moneypunct_byname facet (public member function) | |
destructs a moneypunct_byname facet (protected member function) |
[edit] Example
This example demonistrates how to apply monetary formatting rules of another language without changing the rest of the locale.
#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'; }
Output:
american locale : $12,345.67 american locale with russian moneypunct: 12 345.67 руб
[edit] See also
defines monetary formatting parameters used by std::money_get and std::money_put (class template) |