Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/moneypunct byname"

From cppreference.com
< cpp‎ | locale
(+)
 
m (Text replace - "{{tdcl list begin" to "{{dcl list begin")
Line 13: Line 13:
 
Two specializations are provided by the standard library
 
Two specializations are provided by the standard library
  
{{tdcl list begin}}
+
{{dcl list begin}}
 
{{tdcl list header | locale }}
 
{{tdcl list header | locale }}
 
{{tdcl list item | {{c|std::moneypunct_byname<char, Intl>}} | locale-specific {{c|std::moneypunct}} facet for narrow character I/O }}
 
{{tdcl list item | {{c|std::moneypunct_byname<char, Intl>}} | locale-specific {{c|std::moneypunct}} facet for narrow character I/O }}
Line 20: Line 20:
  
 
===Member types===
 
===Member types===
{{tdcl list begin}}
+
{{dcl list begin}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list item | {{tt|pattern}} | {{c|std::money_base::pattern}}}}
 
{{tdcl list item | {{tt|pattern}} | {{c|std::money_base::pattern}}}}

Revision as of 01:16, 12 June 2012

Template:cpp/locale/sidebar Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <locale>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td class="t-dcl-nopad">
template< class charT, bool Intl = false >
class moneypunct_byname : public std::moneypunct<charT, Intl>;
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

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

Template:tdcl list headerTemplate:tdcl list itemTemplate:tdcl list itemTemplate:tdcl list end

Contents

Member types

Template:tdcl list hitemTemplate:tdcl list itemTemplate:tdcl list itemTemplate:tdcl list end

Member functions

constructs a new moneypunct_byname facet
(public member function)
destructs a moneypunct_byname facet
(protected member function)

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 руб

See also

Template:cpp/locale/dcl list moneypunct