std::ostream_iterator
Da 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. |
Definido no cabeçalho <iterator>
|
||
template< class T, class CharT = char, |
||
std::ostream_iterator
é um iterador de saída de uma única passagem que escreve objetos sucessivos de T
tipo no objeto std::basic_ostream para o qual foi construído, utilizando operator<<
. Delimitador de cadeia opcional é escrito para o fluxo de saída após cada operação de gravação. A operação de escrita é realizada quando o iterador (se dereferenced ou não) é atribuído. Incrementando a std::ostream_iterator
é um não-op.Original:
std::ostream_iterator
is a single-pass output iterator that writes successive objects of type T
into the std::basic_ostream object for which it was constructed, using operator<<
. Optional delimiter string is written to the output stream after every write operation. The write operation is performed when the iterator (whether dereferenced or not) is assigned to. Incrementing the std::ostream_iterator
is a no-op.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.
Em uma implementação típica, os membros de dados apenas de
std::ostream_iterator
são um ponteiro para a std::basic_ostream
associado e um ponteiro para o primeiro caractere na string delimitador.Original:
In a typical implementation, the only data members of
std::ostream_iterator
are a pointer to the associated std::basic_ostream
and a pointer to the first character in the delimiter string.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.
Ao escrever caracteres, std::ostreambuf_iterator é mais eficiente, uma vez que evita a sobrecarga de construção e destruindo o objeto sentinela uma vez por personagem.
Original:
When writing characters, std::ostreambuf_iterator is more efficient, since it avoids the overhead of constructing and destructing the sentry object once per 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.
Índice |
[editar] Tipos de membro
Tipo de membro
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
|
traits_type
|
Traits
|
ostream_type
|
std::basic_ostream<CharT, Traits> |
[editar] Funções de membro
constrói um novo ostream_iterator Original: constructs a new ostream_iterator 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) | |
destrói um ostream_iterator Original: destructs an ostream_iterator 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) | |
escreve um objeto para a seqüência de saída associada Original: writes a object to the associated output sequence 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) | |
no-op (função pública membro) | |
no-op (função pública membro) |
Herdado de std::iterator
Member types
Tipo de membro
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 |
value_type
|
void |
difference_type
|
void |
pointer
|
void |
reference
|
void |
iterator_category
|
std::output_iterator_tag |
[editar] Exemplo
#include <iostream> #include <sstream> #include <iterator> #include <algorithm> int main() { std::istringstream str("0.1 0.2 0.3 0.4"); std::partial_sum( std::istream_iterator<double>(str), std::istream_iterator<double>(), std::ostream_iterator<double>(std::cout, " ")); }
Saída:
0.1 0.3 0.6 1
[editar] Veja também
iterador de saída que escreve para std::basic_streambuf Original: output iterator that writes to std::basic_streambuf The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de classe) | |
iterador de entrada que lê std::basic_istream Original: input iterator that reads from std::basic_istream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (modelo de classe) |