std::num_get
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 <locale>
|
||
template< class CharT, class InputIt = std::istreambuf_iterator<CharT> > class num_get; |
||
Classe
std::num_get encapsule les règles de l'analyse des représentations de chaîne de valeurs de type bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double et void*. Les opérateurs classiques de mise en forme d'entrée (comme cin >> n;) utiliser la facette std::num_get de la localisation du flux d'E / S pour analyser les représentations textuelles des nombres .Original:
Class
std::num_get encapsulates the rules for parsing string representations of values of type bool, unsigned short, unsigned int, long, unsigned long, long long, unsigned long long, float, double, long double, and void*. The standard formatting input operators (such as cin >> n;) use the std::num_get facet of the I/O stream's locale to parse the text representations of the numbers.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.
Inheritance diagram
Exigences de type
-InputIt must meet the requirements of InputIterator.
|
Spécialisations
Deux spécialisations et deux spécialisations partielles sont fournies par la bibliothèque standard et sont mises en œuvre par tous les objets créés dans un environnement linguistique programme C + +:
Original:
Two specializations and two partial specializations are provided by the standard library and are implemented by all locale objects created in a C++ program:
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.
Defined in header
<locale> | |
std::num_get<char>
|
crée l'analyse de chaîne étroite de chiffres
Original: creates narrow string parsing of numbers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_get<wchar_t>
|
crée l'analyse des chaînes gamme de numéros
Original: creates wide string parsing of numbers The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_get<char, InputIt>
|
crée l'analyse de chaîne étroite de nombres à l'aide itérateur d'entrée personnalisé
Original: creates narrow string parsing of numbers using custom input iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std::num_get<wchar_t, InputIt>
|
crée l'analyse des chaînes gamme de numéros à l'aide itérateur d'entrée personnalisé
Original: creates wide string parsing of numbers using custom input iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Types de membres
| Type du membre | Définition |
char_type
|
CharT
|
iter_type
|
InputIt
|
Fonctions membres
construit un nouveau num_get facette Original: constructs a new num_get facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Détruit une facette num_get Original: destructs a num_get facet The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre protégée) | |
Invoque do_get Original: invokes do_get The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) | |
Objets membres
static std::locale::id id |
Id de la localisation Original: id of the locale The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (objet membre public) |
Protégé fonctions membres
[ virtuel ]Original: virtual The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
analyse un certain nombre à partir d'un flux d'entrée Original: parses a number from an input stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre virtuelle protégée) |
Exemple
#include <iostream>
#include <locale>
#include <string>
#include <sstream>
#include <iterator>
int main()
{
std::string de_double = "1.234.567,89";
std::string us_double = "1,234,567.89";
// parse using streams
std::istringstream de_in(de_double);
de_in.imbue(std::locale("de_DE"));
double f1;
de_in >> f1;
std::istringstream us_in(de_double);
us_in.imbue(std::locale("en_US.UTF-8"));
double f2;
us_in >> f2;
std::cout << "Parsing " << de_double << " as double gives " << std::fixed
<< f1 << " in de_DE locale and " << f2 << " in en_US\n";
// use the facet directly
std::istringstream s3(us_double);
s3.imbue(std::locale("en_US.UTF-8"));
auto& f = std::use_facet<std::num_get<char>>(s3.getloc());
std::istreambuf_iterator<char> beg(s3), end;
double f3;
std::ios::iostate err;
f.get(beg, end, s3, err, f3);
std::cout << "parsing " << us_double
<< " as double using raw en_US facet gives " << f3 << '\n';
}
Résultat :
Parsing 1.234.567,89 as double gives 1234567.890000 in de_DE locale and 1.234000 in en_US
parsing 1,234,567.89 as double using raw en_US facet gives 1234567.890000
Voir aussi
définit les règles de ponctuation numériques Original: defines numeric punctuation rules 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) | |
Les valeurs numériques des formats de sortie comme séquence de caractères Original: formats numeric values for output as 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) | |
extraits des données formatées Original: extracts formatted data The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique de std::basic_istream)
| |