std::num_get
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <locale> | ||
template< class CharT, | ||
Classe
std::num_get
incapsula le regole per l'analisi di rappresentazioni di stringa di valori di tipo bool, unsignedshort, unsignedint, long, unsignedlong, longlong, unsignedlonglong, float, double, longdouble e void*. Lo standard di formattazione operatori di input (ad esempio cin >> n;) utilizzare l'aspetto del locale std::num_get
I / O ruscello per analizzare le rappresentazioni di testo dei numeri.Original:
Class
std::num_get
encapsulates the rules for parsing string representations of values of type bool, unsignedshort, unsignedint, long, unsignedlong, longlong, unsignedlonglong, float, double, longdouble, 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.
Indice |
[modifica]Tipo requisiti
-InputIt must meet the requirements of InputIterator . |
[modifica]Specializzazioni
Due specializzazioni e due specializzazioni parziali sono fornite dalla libreria standard e sono attuate da tutti gli oggetti delle impostazioni locali creati in un programma 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.
Definizione nell'header <locale> | |
std::num_get<char> | crea analisi stretta stringa di numeri 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> | crea analisi gamma stringa di numeri 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> | crea analisi stretta stringa di numeri che utilizzano iteratore di input personalizzato 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> | crea analisi gamma stringa di numeri che utilizzano iteratore di input personalizzato 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. |
[modifica]Membri tipi
Membro tipo Original: Member type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | Definition |
char_type | CharT |
iter_type | InputIt |
[modifica]Membri funzioni
costruisce un nuovo aspetto num_get 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. (metodo pubblico) | |
distrugge un aspetto 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. (protetto funzione membro) | |
Invoca 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. (metodo pubblico) |
[modifica]Membri oggetti
static std::locale::id id | ' Id del locale 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. (attributo pubblico) |
[modifica]Protetto funzioni membro
[virtuale] | analizza un numero da un flusso di input 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. (virtuale protetto funzione membro) |
[modifica]Esempio
#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 streamsstd::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 directlystd::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';}
Output:
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
[modifica]Vedi anche
definisce le regole di punteggiatura numerici 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 template) | |
valori formati numerici per l'uscita come sequenza di caratteri 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 template) | |
estratti i dati formattati 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. (metodo pubblico) |