std::ostream_iterator
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 <iterator> | ||
template<class T, class CharT =char, | ||
std::ostream_iterator
es un iterador de salida de un solo paso que escribe objetos sucesivos de T
tipo en el objeto std::basic_ostream para la que fue construido, utilizando operator<<
. Opcional delimitador de cadena se escribe en el flujo de salida después de cada operación de escritura. La operación de escritura se lleva a cabo cuando el iterador (si desreferenciado o no) se asigna a. El incremento del std::ostream_iterator
es un no-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.
En una implementación típica, los miembros de datos sólo de
std::ostream_iterator
son un puntero a la std::basic_ostream
asociado y un puntero al primer carácter en la cadena delimitadora .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.
Al escribir caracteres, std::ostreambuf_iterator es más eficiente, ya que evita la sobrecarga de la construcción y destruyendo el objeto centinela una vez por personaje .
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.
Contenido |
[editar]Tipos de miembros
Miembro de tipo 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]Las funciones miembro
construye una nueva 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. (función miembro pública) | |
destructs un 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. (función miembro pública) | |
escribe un objeto con la secuencia de salida asociado 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. (función miembro pública) | |
no-op (función miembro pública) | |
no-op (función miembro pública) |
Heredado de std::iterator
Member types
Miembro de tipo 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]Ejemplo
Ejecuta este código
#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, " "));}
Salida:
0.1 0.3 0.6 1
[editar]Ver también
Iterador de salida que escribe a un búfer de flujo (std::basic_streambuf). (plantilla de clase) | |
Iterador de entrada que lee de un flujo de entrada (std::basic_istream). (plantilla de clase) |