std::num_put::put, std::num_put::do_put
De cppreference.com
|
|
Esta página se ha traducido por ordenador/computador/computadora de la versión en inglés de la Wiki usando Google Translate.
La traducción puede contener errores y palabras aparatosas/incorrectas. Planea sobre el texto para ver la versión original. Puedes ayudar a corregir los errores y mejorar la traducción. Para instrucciones haz clic aquí. |
| Definido en el archivo de encabezado <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)
función miembro pública, llama a la función virtual protegido
do_put miembro de la clase más derivada .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)
escribe los caracteres a la
out secuencia de salida que representan el valor de v, con el formato requerido por las banderas de formato str.flags() y las facetas std::numpunct y std::ctype de la configuración regional imbuida en la str corriente. Esta función es llamada por todos los operadores de flujo con formato de salida, como 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 conversión ocurre en cuatro etapas
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.
Etapa 1: Conversión de selección especificador
- I / O banderas de formato se obtienen, como porOriginal: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);
- Si el tipo de
vesboolOriginal: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. - * Si
boolalpha == 0, a continuación, convierte al tipovinty lleva a cabo la producción entero .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. - * Si obtiene
boolalpha != 0std::use_facet<std::numpunct<charT>>(str.getloc()).truename()siv == trueostd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()siv == false, y envía cadaccarácter sucesivo de esa cadena aoutcon*out++ = c. Sin ulterior elaboración se hace en este caso, la función devuelveout.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. - Si el tipo de
ves un tipo entero, la elección de la primera aplicable de las cinco siguientes se selecciona: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.
- Si
basefield == oct, utilizará especificador de conversión%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. - Si
basefield == hex && !uppercase, utilizará especificador de conversión%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. - Si
basefield == hex, utilizará especificador de conversión%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. - Si el tipo de
vestá firmado, usaremos la conversión especificador%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. - Si el tipo de
vno está firmado, usaremos la conversión especificador%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.
- Para tipos de enteros, modificador de longitud se añade a la especificación de la conversión si es necesario:
lparalongyunsigned long,llparalong longyunsigned 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. - Si el tipo de
ves un tipo de punto flotante, la elección de la primera aplicable de las cinco siguientes se selecciona: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.
- Si
floatfield == std::ios_base::fixed, utilizará especificador de conversión%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. - Si
floatfield == std::ios_base::scientific && !uppercase, utilizará especificador de conversión%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. - Si
floatfield == std::ios_base::scientific, utilizará especificador de conversión%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. - Si
floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, utilizará especificador de conversión%a(desde C++11)Original:Iffloatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, will use conversion specifier%a(desde C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si
floatfield == std::ios_base::fixed | std::ios_base::scientific, utilizará especificador de conversión%A(desde C++11)Original:Iffloatfield == std::ios_base::fixed | std::ios_base::scientific, will use conversion specifier%A(desde C++11)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - Si
!uppercase, utilizará especificador de conversión%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. - de lo contrario, va a utilizar la conversión especificador
%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.
- * Si el tipo de
veslong double, laLmodificador de longitud se añade al indicador de conversión .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. - * Además, si
floatfield != (ios_base::fixed | ios_base::scientific), entonces modificador se añade precisión, ajuste astr.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. - Para ambos tipos de enteros y de punto flotante, si
showbasese establece, el#modificador se antepone. Sishowposse establece, el+modificador se antepone .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. - Si el tipo de
vesvoid*, se utilizan la conversión especificador%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 cadena de caracteres estrecho se crea como si de una llamada a
std::printf(spec, v)en la localización "C", dondespeces el especificador de conversión elegido .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.
Etapa 2: configuración regional específica conversión
- Cada carácter
cobtenido en la etapa 1, con excepción de la'.'punto decimal, se convierte aCharTllamandostd::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. - Para los tipos aritméticos, el carácter separador de miles, obtenido a partir de
std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), se inserta en la secuencia de acuerdo con las reglas de agrupamiento proporcionados porstd::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. - Carácter de punto decimal (
'.') se sustituyen porstd::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.
Etapa 3: relleno
- La bandera de ajuste se obtiene como por
std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield))y se examinaron para identificar la ubicación relleno, como sigueOriginal: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.
- Si
adjustfield == std::ios_base::left, se rellenará despuésOriginal: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. - Si
adjustfield == std::ios_base::right, se rellenará antesOriginal: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. - Si
adjustfield == std::ios_base::internaly un carácter de signo se produce en la representación, se rellenará después de la señalOriginal: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. - Si
adjustfield == std::ios_base::internaly representación de la Etapa 1 se inició con 0x o 0X, se rellenará después de la 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. - de lo contrario, se rellenará antesOriginal: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.
- Si
str.width()no es cero (std::setw por ejemplo, se utilizó sólo) y el número de la gráfica, después de la etapa 2 es menor questr.width(), entonces copias del carácterfillse insertan en la posición indicada por el relleno para que la duración de la secuencia destr.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.
Etapa 4: salida
Cada
c carácter sucesivo a partir de la secuencia de la gráfica de la Etapa 3 se emite como por *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.
Parámetros
| out | - | iterador que apunta al primer carácter que se sobrescriba
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 | - | transmitir a recuperar la información de formato de
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 | - | carácter de relleno utilizado cuando los resultados debe ser acolchado para el ancho de 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 | - | valor para convertir en una cadena y la producción
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. |
Valor de retorno
out
Notas
El cero inicial generado por la especificación de conversión
#o (resultante de la combinación de std::showbase y std::oct por ejemplo) no se cuenta como un carácter de relleno .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.
Ejemplo
Genere un número usando la configuración regional global
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.
Ejecuta este código
#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';
}Salida:
2,71Ver también
| Inserta datos con formato. (función miembro pública de std::basic_ostream<CharT,Traits>)
|