std::get_money
De 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>| Déclaré dans l'en-tête <iomanip>
|
||
template< class MoneyT > /*unspecified*/ get_money( MoneyT& mon, bool intl = false ); |
(depuis C++11) | |
Lorsque utilisées dans une expression
in >> get_money(mon, intl), analyse la saisie de caractères comme une valeur monétaire, tel que spécifié par la facette std::money_get de la locale courante imprégné dans in, et stocke la valeur dans mon .Original:
When used in an expression
in >> get_money(mon, intl), parses the character input as a monetary value, as specified by the std::money_get facet of the locale currently imbued in in, and stores the value in mon.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.
Cette fonction se comporte comme une fonction de saisie formatée .
Original:
This function behaves as a formatted input 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.
Paramètres
| mon | - | la variable dont la valeur monétaire sera écrite. Peut être
long double ou basic_stringOriginal: variable where monetary value will be written. Can be 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 | - | s'attend à trouver des chaînes de devises internationales nécessaires si
true, s'attend à ce que les symboles monétaires option contraireOriginal: expects to find required international currency strings if true, expects optional currency symbols otherwiseThe text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Retourne la valeur
Retourne un objet de type non précisé de sorte que si
in est le nom d'un flux de sortie de std::basic_istream<CharT, Traits> type, le in >> get_money(mon, intl) expression se comporte comme si le code suivant est exécuté:Original:
Returns an object of unspecified type such that if
in is the name of an output stream of type std::basic_istream<CharT, Traits>, then the expression in >> get_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::istreambuf_iterator<CharT, Traits> Iter; typedef std::money_get<CharT, Iter> MoneyGet; std::ios_base::iostate err = std::ios_base::goodbit; const MoneyGet &mg = std::use_facet<MoneyGet>(in.getloc()); mg.get(Iter(in.rdbuf()), Iter(), intl, in, err, mon); if (std::ios_base::goodbit != err) out.setstate(err);
Exemple
#include <iostream>
#include <sstream>
#include <locale>
#include <iomanip>
int main()
{
std::istringstream in("$1,234.56 2.22 USD 3.33");
long double v1, v2;
std::string v3;
in.imbue(std::locale("en_US.UTF-8"));
in >> std::get_money(v1) >> std::get_money(v2) >> std::get_money(v3, true);
std::cout << '"' << in.str() << "\" parsed as: "
<< v1 << ", " << v2 << ", " << v3 << '\n';
}
Résultat :
"$1,234.56 2.22 USD 3.33" parsed as: 123456, 222, 333
Voir aussi
analyse et construit une valeur monétaire à partir d'une séquence de caractères d'entrée Original: parses and constructs a monetary value from an input character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe générique) | |
(C++11) |
formats et des sorties d'une valeur monétaire Original: formats and outputs 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. (fonction générique) |