std::num_put::put, std::num_put::do_put
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>| Definido no cabeçalho <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)
função de membro público, chama a
do_put função virtual protegido membro da classe derivada mais.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)
escreve caracteres ao
out seqüência de saída que representa o valor de v, formatado conforme solicitado pelas bandeiras de formatação str.flags() e as facetas std::numpunct e std::ctype da localidade imbuídos no str fluxo. Esta função é chamada por todos os operadores de saída formatados fluxo, 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.
A conversão ocorre em quatro 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.
Fase 1: conversão seleção especificador
- I / O formato bandeiras são obtidos, como se 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);
- Se o tipo de
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, em seguida, converte o tipovinte realiza a saída inteiro.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 != 0obtémstd::use_facet<std::numpunct<charT>>(str.getloc()).truename()sev == trueoustd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()sev == falsee produz cadaccaráter sucessivo de corda para queoutcom*out++ = c. Nenhum processamento adicional é feita, neste caso, a função retornaout.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 o tipo de
vé um tipo inteiro, a escolha do primeiro dos cinco aplicável seguinte é selecionado: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, vai usar especificador de conversão%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, vai usar especificador de conversão%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, vai usar especificador de conversão%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 o tipo de
vé assinado, vai usar a conversão 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. - Se o tipo de
vnão é assinado, vai usar a conversão 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 inteiros, modificador de comprimento é adicionado à especificação de conversão se necessário:
lparalongeunsigned long,llparalong 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 o tipo de
vé um tipo de ponto flutuante, a escolha do primeiro dos cinco aplicável seguinte é selecionado: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, vai usar especificador de conversão%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, vai usar especificador de conversão%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, vai usar especificador de conversão%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, vai usar especificador de conversão%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. - Se
floatfield == std::ios_base::fixed | std::ios_base::scientific, vai usar especificador de conversão%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. - Se
!uppercase, vai usar especificador de conversão%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. - caso contrário, irá usar a conversão 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.
- * Se o tipo de
vélong double, oLmodificador de comprimento é adicionado ao especificador de conversão.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. - * Além disso, se
floatfield != (ios_base::fixed | ios_base::scientific), então modificador de precisão é adicionado, definido parastr.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 os tipos inteiros e ponto flutuante, se
showbaseé definido, o#modificador é adicionado. Seshowposé definido, o+modificador é prefixado.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 o tipo de
vévoid*, vai usar especificador de conversão%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. - Uma cadeia de caracteres estreita é criado como se por uma chamada para
std::printf(spec, v)na localidade "C", ondespecé o especificador de conversão escolhida.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: localidade específica de conversão
- Cada carácter
cobtido na fase 1, que não seja o ponto decimal'.', é convertido emCharTchamandostd::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 tipos aritméticos, o caractere separador de milhares, obtido a partir de
std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), é inserida a sequência de acordo com as regras de agrupamento fornecido 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. - Caracteres ponto decimal (
'.') são substituídos 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.
Fase 3: estofamento
- A bandeira de ajustamento é obtido como se por
std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield))e examinadas para identificar a localização de preenchimento, como se 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, irá preencher depoisOriginal: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, irá preencher 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. - Se
adjustfield == std::ios_base::internale um carácter de sinal ocorre na representação, irá preencher após o sinalOriginal: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 representação Stage 1 começou com 0x ou 0X, irá preencher depois do x ou 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 outro modo, irá preencher 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.
- Se
str.width()é diferente de zero (std::setw exemplo foi utilizado apenas) e o número de gráfico após Fase 2 é menor do questr.width(), em seguida, as cópias do carácterfillsão inseridas na posição indicada por acolchoamento para trazer o comprimento da sequência 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.
Fase 4: saída
Cada
c caráter sucessivo a partir da seqüência de gráfico de Fase 3 é a saída, como se 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 apontando para o primeiro personagem a ser substituído
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 para recuperar as informações de formatação 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 | - | caractere de preenchimento utilizado quando os resultados precisam ser preenchidos para a largura do 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 a ser convertido para string e saída
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
O zero inicial gerada pela especificação de conversão
#o (resultante da combinação de std::showbase e std::oct por exemplo) não é contado como um caractere de preenchimento.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.
Exemplo
Saída de um número usando a localização 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.
#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';
}Saída:
2,71Veja também
insere dados formatados 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. (of std::basic_ostream função pública membro)
| |