Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/locale/moneypunct"

From cppreference.com
< cpp‎ | locale
m (Text replace - "{{example cpp" to "{{example")
m (Text replace - "{{cpp|" to "{{c|")
Line 9: Line 9:
 
{{ddcl list end}}
 
{{ddcl list end}}
  
The facet {{cpp|std::moneypunct}} encapsulates monetary value format preferences. Stream I/O manipulators {{cpp|std::get_money}} and {{cpp|std::put_money}} use {{cpp|std::moneypunct}} through {{cpp|std::money_get}} and {{cpp|std::money_put}} for parsing monetary value input and formatting monetary value output.  
+
The facet {{c|std::moneypunct}} encapsulates monetary value format preferences. Stream I/O manipulators {{c|std::get_money}} and {{c|std::put_money}} use {{c|std::moneypunct}} through {{c|std::money_get}} and {{c|std::money_put}} for parsing monetary value input and formatting monetary value output.  
  
 
Four specializations are provided by the standard library
 
Four specializations are provided by the standard library
Line 15: Line 15:
 
{{tdcl list begin}}
 
{{tdcl list begin}}
 
{{tdcl list header | locale }}
 
{{tdcl list header | locale }}
{{tdcl list item | {{cpp|std::moneypunct<char>}}          | provides equivalents of the "C" locale preferences }}
+
{{tdcl list item | {{c|std::moneypunct<char>}}          | provides equivalents of the "C" locale preferences }}
{{tdcl list item | {{cpp|std::moneypunct<wchar_t>}}      | provides wide character equivalents of the "C" locale preferences }}
+
{{tdcl list item | {{c|std::moneypunct<wchar_t>}}      | provides wide character equivalents of the "C" locale preferences }}
{{tdcl list item | {{cpp|std::moneypunct<char, true>}}    | provides equivalents of the "C" locale preferences, with international currency symbols }}
+
{{tdcl list item | {{c|std::moneypunct<char, true>}}    | provides equivalents of the "C" locale preferences, with international currency symbols }}
{{tdcl list item | {{cpp|std::moneypunct<wchar_t, true>}} | provides wide character equivalents of the "C" locale preferences, with international currency symbols }}
+
{{tdcl list item | {{c|std::moneypunct<wchar_t, true>}} | provides wide character equivalents of the "C" locale preferences, with international currency symbols }}
 
{{tdcl list end}}
 
{{tdcl list end}}
  
Line 25: Line 25:
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list item | {{tt|char_type}} | {{tt|charT}}}}
 
{{tdcl list item | {{tt|char_type}} | {{tt|charT}}}}
{{tdcl list item | {{tt|string_type}} | {{cpp|std::basic_string<charT>}}}}
+
{{tdcl list item | {{tt|string_type}} | {{c|std::basic_string<charT>}}}}
 
{{tdcl list end}}
 
{{tdcl list end}}
  
Line 37: Line 37:
 
{{tdcl list begin}}
 
{{tdcl list begin}}
 
{{tdcl list hitem | Member | Type}}
 
{{tdcl list hitem | Member | Type}}
{{tdcl list item | {{tt|id}} {{mark|static}} | {{cpp|std::locale::id}} }}
+
{{tdcl list item | {{tt|id}} {{mark|static}} | {{c|std::locale::id}} }}
 
{{tdcl list end}}
 
{{tdcl list end}}
  
Line 72: Line 72:
 
{{tdcl list begin}}
 
{{tdcl list begin}}
 
{{tdcl list hitem | Member type | Definition}}
 
{{tdcl list hitem | Member type | Definition}}
{{tdcl list item | {{cpp|enum part { none, space, symbol, sign, value };}} | unscoped enumeration type}}
+
{{tdcl list item | {{c|enum part { none, space, symbol, sign, value };}} | unscoped enumeration type}}
{{tdcl list item | {{cpp|struct pattern { char field[4]; };}} | the monetary format type}}
+
{{tdcl list item | {{c|struct pattern { char field[4]; };}} | the monetary format type}}
 
{{tdcl list end}}
 
{{tdcl list end}}
  

Revision as of 19:55, 19 April 2012

Template:cpp/locale/moneypunct/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 International = false >
class moneypunct : public std::locale::facet, public std::money_base;
</td>

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

The facet std::moneypunct encapsulates monetary value format preferences. Stream I/O manipulators std::get_money and std::put_money use std::moneypunct through std::money_get and std::money_put for parsing monetary value input and formatting monetary value output.

Four specializations are provided by the standard library

Template:tdcl list begin Template:tdcl list header Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list end

Contents

Member types

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list item Template:tdcl list end

Member constants

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list end

Member objects

Template:tdcl list begin Template:tdcl list hitem Template:tdcl list item Template:tdcl list end

Member functions

constructs a new moneypunct facet
(public member function)
destructs a moneypunct facet
(protected member function)
invokes do_decimal_point
(public member function)
invokes do_thousands_sep
(public member function)
invokes do_grouping
(public member function)
invokes do_curr_symbol
(public member function)
invokes do_positive_sign
(public member function)
invokes do_negative_sign
(public member function)
invokes do_frac_digits
(public member function)
invokes do_pos_format
(public member function)
invokes do_neg_format
(public member function)

Protected member functions

provides the character to use as decimal point
(virtual protected member function)
provides the character to use as thousands separator
(virtual protected member function)
[virtual]
provides the numbers of digits between each pair of thousands separators
(virtual protected member function)
provides the string to use as the currency identifier
(virtual protected member function)
provides the string to indicate a positive value
(virtual protected member function)
provides the string to indicate a negative value
(virtual protected member function)
provides the number of digits to display after the decimal point
(virtual protected member function)
provides the formatting pattern for positive values
(virtual protected member function)
provides the formatting pattern for negative values
(virtual protected member function)

Example

#include <iostream>
#include <locale>
int main()
{
    std::locale jp("ja_JP.UTF-8");
    std::cout << "japanese currency symbol is "
              << std::use_facet<std::moneypunct<char, true>>(jp).curr_symbol()
              << "or "
              << std::use_facet<std::moneypunct<char>>(jp).curr_symbol()
              << " for short\n";
}

Output:

japanese currency symbol is JPY or ¥ for short

See also

Template:cpp/locale/dcl list money baseTemplate:cpp/locale/dcl list moneypunct bynameTemplate:cpp/locale/dcl list money getTemplate:cpp/locale/dcl list money put