operator<<<div class="t-tr-text">(Std :: basic_ostream)<div class="t-tr-dropdown"><div><div><div class="t-tr-dropdown-arrow-border"></div><div class="t-tr-dropdown-arrow"></div><div class="t-tr-dropdown-h">Original:</div><div class="t-tr-dropdown-orig">(std::basic_ostream)</div><div class="t-tr-dropdown-notes">The text has been machine-translated via [http://translate.google.com Google Translate].<br/> You can help to correct and verify the translation. Click [http://en.cppreference.com/w/Cppreference:MachineTranslations here] for instructions.</div></div></div></div></div>
![]() | 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. |
template<class CharT, class Traits> basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, | (1) | |
template<class CharT, class Traits > basic_ostream<CharT,Traits>& operator<<( basic_ostream<CharT,Traits>& os, | (2) | |
template<class CharT, class Traits, class T > basic_ostream< charT, traits >& operator<<( basic_ostream<CharT,Traits>&& os, | (3) | (desde C++11) |
You can help to correct and verify the translation. Click here for instructions.
sentry
tipo, o que esvazia os buffers de saída tie()'d se necessário e verifica os erros de fluxo. Após a construção, se os retornos de sentinela objeto false, essas funções retornam sem tentar qualquer saída. Se ocorrer um erro durante a saída, estas funções chamam setstate(ios_base::failbit). Se uma exceção é lançada durante a saída, então ios :: badbit está definido (a exceção é suprimida a menos exceptions()&badbit)!=0, caso em que é relançada)sentry
, which flushes the tie()'d output buffers if necessary and checks the stream errors. After construction, if the sentry object returns false, these functions return without attempting any output. If an error occurs during output, these functions call setstate(ios_base::failbit). If an exception is thrown during output, then ios::badbit is set (the exception is suppressed unless exceptions()&badbit)!=0, in which case it is rethrown)You can help to correct and verify the translation. Click here for instructions.
ch
personagem. Se o tipo de caracteres não é CharT
, ele é primeiro convertido com os.widen(ch). O preenchimento é determinado como se de Fase 3 de num_put::put(). Após a inserção, é chamado width(0).ch
. If the type of the character is not CharT
, it is first converted with os.widen(ch). Padding is determined as if by Stage 3 of num_put::put(). After insertion, width(0) is called.You can help to correct and verify the translation. Click here for instructions.
s
.s
.You can help to correct and verify the translation. Click here for instructions.
- para as sobrecargas primeiro e terceiro (onde
CharT
corresponde ao tipo dech
), exatamentetraits::length(s)
personagens estão inseridos.Original:for the first and third overloads (whereCharT
matches the type ofch
), exactlytraits::length(s)
characters are inserted.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - para a segunda sobrecarga, exatamente std::char_traits<char>::length(s) personagens estão inseridos.Original:for the second overload, exactly std::char_traits<char>::length(s) characters are inserted.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - para os dois últimos sobrecargas, exatamente traits::length(reinterpret_cast<constchar*>(s)) estão inseridos.Original:for the last two overloads, exactly traits::length(reinterpret_cast<constchar*>(s)) are inserted.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.
You can help to correct and verify the translation. Click here for instructions.
Índice |
[editar]Parâmetros
os | - | saída de fluxo de dados para inserir Original: output stream to insert data to The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
ch | - | referência a um personagem para inserir Original: reference to a character to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
s | - | ponteiro para uma cadeia de caracteres para inserir Original: pointer to a character string to insert The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[editar]Valor de retorno
st
[editar]Exemplo
#include <iostream>#include <sstream>int main(){std::cout<<"Hello, world"// the const char* overlaod<<'\n';// the char overloadstd::string s =(std::ostringstream()<<1.2).str();// rvalue overloadstd::cout<< s <<'\n';}
Saída:
Hello, world 1.2
[editar]Veja 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. (função pública membro) |