std::num_put::put, std::num_put::do_put
Da cppreference.com.
(Reindirizzamento da cpp/locale/num put/do put)
|
|
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. |
<metanoindex/>
<tbody> </tbody>| Elemento definito nell'header <locale>
|
||
public: iter_type put( iter_type out, std::ios_base& str, char_type fill, bool v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, long v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, long long v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long long v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, double v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, long double v) const; iter_type put( iter_type out, std::ios_base& str, char_type fill, const void* v) const; |
(1) | |
protected: iter_type do_put( iter_type out, std::ios_base& str, char_type fill, bool v) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long v) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long long v) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long long) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, double v) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long double v) const; iter_type do_put( iter_type out, std::ios_base& str, char_type fill, const void* v) const; |
(2) | |
1)
funzione membro pubblica, chiama il virtuale protetto
do_put funzione membro della classe più derivata.Original:
public member function, calls the protected virtual member function
do_put of the most derived class.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.
2)
scrive caratteri a
out sequenza di emissione che rappresentano il valore di v, nel formato richiesto dalle bandiere di formattazione str.flags() e le sfaccettature std::numpunct e std::ctype del locale intrisa nel str flusso. Questa funzione viene chiamata da tutti gli operatori in formato streaming in uscita, come ad esempio std::cout << n;.Original:
writes characters to the output sequence
out which represent the value of v, formatted as requested by the formatting flags str.flags() and the std::numpunct and std::ctype facets of the locale imbued in the stream str. This function is called by all formatted output stream operators, such as std::cout << n;.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.
La conversione avviene in quattro fasi
Original:
Conversion occurs in four stages
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.
Fase 1: selezione specificatore di conversione
- I / O flags formato sono ottenuti, come perOriginal:I/O format flags are obtained, as if byThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fmtflags basefield = (str.flags() & std::ios_base::basefield);fmtflags uppercase = (str.flags() & std::ios_base::uppercase);fmtflags floatfield = (str.flags() & std::ios_base::floatfield);fmtflags showpos = (str.flags() & std::ios_base::showpos);fmtflags showbase = (str.flags() & std::ios_base::showbase);
- Se il tipo di
vèboolOriginal:If the type ofvisboolThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Se
boolalpha == 0, quindi convertevdigitareinted esegue uscita intero.Original:* Ifboolalpha == 0, then convertsvto typeintand performs integer output.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Se
boolalpha != 0ottienestd::use_facet<std::numpunct<charT>>(str.getloc()).truename()sev == trueostd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()sev == false, ed emette ognicsuccessivo carattere della stringa dioutcon*out++ = c. Nessun ulteriore elaborazione avviene in questo caso, la funzione restituisceout.Original:* Ifboolalpha != 0obtainsstd::use_facet<std::numpunct<charT>>(str.getloc()).truename()ifv == trueorstd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()ifv == false, and outputs each successive charactercof that string tooutwith*out++ = c. No further processing is done in this case, the function returnsout.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se il tipo di
vè di tipo intero, la prima scelta applicabili delle seguenti cinque è selezionato:Original:If the type ofvis an integer type, the the first applicable choice of the following five is selected:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se
basefield == oct, utilizzerà specificatore di conversione%oOriginal:Ifbasefield == oct, will use conversion specifier%oThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
basefield == hex && !uppercase, utilizzerà specificatore di conversione%xOriginal:Ifbasefield == hex && !uppercase, will use conversion specifier%xThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
basefield == hex, utilizzerà specificatore di conversione%XOriginal:Ifbasefield == hex, will use conversion specifier%XThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se il tipo di
vè firmato, utilizzerà specificatore di conversione%dOriginal:If the type ofvis signed, will use conversion specifier%dThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se il tipo di
vnon è firmato, userà specificatore di conversione%uOriginal:If the type ofvis unsigned, will use conversion specifier%uThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Per i tipi interi, modificatore di lunghezza viene aggiunto alla specifica di conversione, se necessario:
lperlongeunsigned long,llperlong longeunsigned long long.Original:For integer types, length modifier is added to the conversion specification if necessary:lforlongandunsigned long,llforlong longandunsigned long long.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se il tipo di
vè un tipo a virgola mobile, la prima scelta del caso dei seguenti cinque è selezionato:Original:If the type ofvis a floating-point type, the the first applicable choice of the following five is selected:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se
floatfield == std::ios_base::fixed, utilizzerà specificatore di conversione%fOriginal:Iffloatfield == std::ios_base::fixed, will use conversion specifier%fThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
floatfield == std::ios_base::scientific && !uppercase, utilizzerà specificatore di conversione%eOriginal:Iffloatfield == std::ios_base::scientific && !uppercase, will use conversion specifier%eThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
floatfield == std::ios_base::scientific, utilizzerà specificatore di conversione%EOriginal:Iffloatfield == std::ios_base::scientific, will use conversion specifier%EThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, utilizzerà specificatore di conversione%a(dal C++11)Original:Iffloatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, will use conversion specifier%a(dal C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
floatfield == std::ios_base::fixed | std::ios_base::scientific, utilizzerà specificatore di conversione%A(dal C++11)Original:Iffloatfield == std::ios_base::fixed | std::ios_base::scientific, will use conversion specifier%A(dal C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
!uppercase, utilizzerà specificatore di conversione%gOriginal:If!uppercase, will use conversion specifier%gThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - in caso contrario, verrà utilizzato specificatore di conversione
%GOriginal:otherwise, will use conversion specifier%GThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- * Se il tipo di
vèlong double, ilLmodificatore di lunghezza viene aggiunto lo specificatore di conversione.Original:* If the type ofvislong double, the length modifierLis added to the conversion specifier.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - * Inoltre, se
floatfield != (ios_base::fixed | ios_base::scientific), quindi modificatore di precisione si aggiunge, impostato sustr.precision()Original:* Additionally, iffloatfield != (ios_base::fixed | ios_base::scientific), then precision modifier is added, set tostr.precision()The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Per entrambi i tipi interi e in virgola mobile, se
showbaseè impostata, il#modificatore viene anteposta. Seshowposè impostato, il+modificatore viene anteposta.Original:For both integer and floating-point types, ifshowbaseis set, the modifier#is prepended. Ifshowposis set, the modifier+is prepended.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se il tipo di
vèvoid*, userà specificatore di conversione%pOriginal:If the type ofvisvoid*, will use conversion specifier%pThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Una stringa di caratteri ristretto viene creato come se da una chiamata al
std::printf(spec, v)nel locale "C", dovespecè lo specificatore di conversione scelto.Original:A narrow character string is created as if by a call tostd::printf(spec, v)in the "C" locale, wherespecis the chosen conversion specifier.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Fase 2: specifica delle impostazioni locali di conversione
- Ogni
ccarattere ottenuto nella Fase 1, ad eccezione della'.'punto decimale, viene convertito inCharTchiamandostd::use_facet<std::ctype<CharT>>(str.getloc()).widen(c).Original:Every charactercobtained in Stage 1, other than the decimal point'.', is converted toCharTby callingstd::use_facet<std::ctype<CharT>>(str.getloc()).widen(c).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Per i tipi aritmetici, il separatore di migliaia di caratteri, ottenuto da
std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), viene inserito nella sequenza secondo le regole di raggruppamento fornite dastd::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()Original:For arithmetic types, the thousands separator character, obtained fromstd::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), is inserted into the sequence according to the grouping rules provided bystd::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Caratteri punto decimale (
'.') sono sostituiti dastd::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()Original:Decimal point characters ('.') are replaced bystd::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Fase 3: imbottitura
- Il flag di regolazione è ottenuta come per
std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield))ed esaminati per identificare la posizione padding, come segueOriginal:The adjustment flag is obtained as if bystd::fmtflags adjustfield = (flags & (std::ios_base::adjustfield))and examined to identify padding location, as followsThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se
adjustfield == std::ios_base::left, verranno inseriti dopoOriginal:Ifadjustfield == std::ios_base::left, will pad afterThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
adjustfield == std::ios_base::right, verranno inseriti primaOriginal:Ifadjustfield == std::ios_base::right, will pad beforeThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
adjustfield == std::ios_base::internale un carattere di segno si verifica nella rappresentazione, verranno inseriti dopo il segnoOriginal:Ifadjustfield == std::ios_base::internaland a sign character occurs in the representation, will pad after the signThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Se
adjustfield == std::ios_base::internale Stage 1 Rappresentazione iniziato con 0x o 0X, verranno inseriti dopo l'x o XOriginal:Ifadjustfield == std::ios_base::internaland Stage 1 representation began with 0x or 0X, will pad after the x or XThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - altrimenti, verranno inseriti primaOriginal:otherwise, will pad beforeThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se
str.width()è non-zero (std::setw esempio è stato usato solo) e il numero di grafico dopo Stage 2 è inferiorestr.width(), quindi copie del caratterefillvengono inseriti nella posizione indicata da imbottitura per portare la lunghezza della sequenza distr.width().Original:Ifstr.width()is non-zero (e.g. std::setw was just used) and the number of CharT's after Stage 2 is less thanstr.width(), then copies of thefillcharacter are inserted at the position indicated by padding to bring the length of the sequence tostr.width().The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Fase 4: uscita
Ogni
c carattere successivo alla sequenza di grafico dalla fase 3 è uscita come per *out++ = c.Original:
Every successive character
c from the sequence of CharT's from Stage 3 is output as if by *out++ = c.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.
Parametri
| out | - | iteratore che punta al primo carattere da sovrascrivere
Original: iterator pointing to the first character to be overwritten The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| str | - | streaming per recuperare le informazioni di formattazione da
Original: stream to retrieve the formatting information from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| fill | - | carattere di riempimento utilizzato quando i risultati devono essere imbottite per la larghezza del campo
Original: padding character used when the results needs to be padded to the field width The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
| v | - | valore da convertire in stringa e di uscita
Original: value to convert to string and output The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Valore di ritorno
out
Note
Lo zero iniziale generata dalla specifica di conversione
#o (risultante dalla combinazione di std::showbase e std::oct per esempio) non viene conteggiato come un carattere di riempimento.Original:
The leading zero generated by the conversion specification
#o (resulting from the combination of std::showbase and std::oct for example) is not counted as a padding character.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.
Esempio
Output di un numero utilizzando locale globale
Original:
Output a number using global locale
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.
#include <iostream>
#include <locale>
int main()
{
auto &facet = std::use_facet<std::num_put<char>>(std::locale());
facet.put(std::cout, std::cout, '0', 2.71);
std::cout << '\n';
}Output:
2,71Vedi anche
inserisce i dati formattati Original: inserts 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) | |