std::put_money
Aus cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
<metanoindex/>
<tbody> </tbody>| definiert in Header <iomanip>
|
||
template< class MoneyT > /*unspecified*/ put_money( const MoneyT& mon, bool intl = false ); |
(seit C++11) | |
Wenn in einem Ausdruck
out << put_money(mon, intl) verwendet, wandelt der monetäre Wert mon seinen Charakter Darstellung als durch die std::money_put Facette der locale derzeit in out durchdrungen angegeben .Original:
When used in an expression
out << put_money(mon, intl), converts the monetary value mon to its character representation as specified by the std::money_put facet of the locale currently imbued in out.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Diese Funktion verhält sich wie eine formatierte Ausgabe Funktion .
Original:
This function behaves as a formatted output function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Parameter
| mon | - | einen monetären Wert, entweder
long double oder basic_stringOriginal: a monetary value, either long double or basic_stringThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| intl | - | Verwenden internationale Währung Saiten, wenn
true, verwenden Währungssymbole andersOriginal: use international currency strings if true, use currency symbols otherwiseThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Rückgabewert
Gibt ein Objekt vom angegebenen Typ, so dass, wenn
out der Name eines Output-Stream vom Typ std::basic_ostream<CharT, Traits> ist, dann ist der Ausdruck out << put_money(mon, intl) wie verhält, wenn der folgende Code ausgeführt wurde:Original:
Returns an object of unspecified type such that if
out is the name of an output stream of type std::basic_ostream<CharT, Traits>, then the expression out << put_money(mon, intl) behaves as if the following code was executed:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
typedef std::ostreambuf_iterator<CharT, Traits> Iter; typedef std::money_put<CharT, Iter> MoneyPut; const MoneyPut& mp = std::use_facet<MoneyPut>(out.getloc()); const Iter end = mp.put(Iter(out.rdbuf()), intl, out, out.fill(), mon); if (end.failed()) out.setstate(std::ios::badbit);
Beispiel
#include <iostream>
#include <iomanip>
int main()
{
long double mon = 123.45; // or std::string mon = "123.45";
std::cout.imbue(std::locale("en_US.utf8"));
std::cout << std::showbase
<< "en_US: " << std::put_money(mon) << " or " << std::put_money(mon, true) << '\n';
std::cout.imbue(std::locale("ru_RU.utf8"));
std::cout << "ru_RU: " << std::put_money(mon) << " or " << std::put_money(mon, true) << '\n';
std::cout.imbue(std::locale("ja_JP.utf8"));
std::cout << "ja_JP: " << std::put_money(mon) << " or " << std::put_money(mon, true) << '\n';
}
Output:
en_US: $1.23 or USD 1.23
ru_RU: 1.23 руб or 1.23 RUB
ja_JP: ¥123 or JPY 123
Siehe auch
Formate einen monetären Wert für die Ausgabe als Zeichenfolge Original: formats a monetary value for output as a character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Klassen-Template) | |
(C++11) |
parst einen monetären Wert Original: parses a monetary value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktions-Template) |