std::ostream_iterator
Aus 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. |
definiert in Header <iterator>
|
||
template< class T, class CharT = char, |
||
std::ostream_iterator
ist ein Single-Pass-Output-Iterator, die aufeinanderfolgende Objekte vom Typ T
schreibt in den std::basic_ostream Objekt, für das es konstruiert wurde, mit operator<<
. Optional Trennzeichenfolge an den Ausgabe-Stream nach jedem Schreibvorgang geschrieben. Die Schreiboperation durchgeführt wird, wenn der Iterator (ob oder nicht dereferenziert) zugeordnet ist. Inkrementieren des std::ostream_iterator
ist ein 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.
In einer typischen Implementierung sind die einzigen Daten, die Mitglieder der
std::ostream_iterator
ein Zeiger auf die zugeordneten std::basic_ostream
und einen Zeiger auf das erste Zeichen in der Trennzeichenfolge .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.
Beim Schreiben Zeichen ist std::ostreambuf_iterator effizienter, da sie den Aufwand für den Bau und zerstören die Wache Objekt einmal pro Charakter verhindert .
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.
Inhaltsverzeichnis |
[Bearbeiten] Mitglied Typen
Mitglied Typ
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> |
[Bearbeiten] Member-Funktionen
baut eine neue 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. (öffentliche Elementfunktion) | |
zerstört sich eine 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. (öffentliche Elementfunktion) | |
schreibt ein Objekt an den zugehörigen Ausgang Sequenz 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. (öffentliche Elementfunktion) | |
no-op (öffentliche Elementfunktion) | |
no-op (öffentliche Elementfunktion) |
Inherited from std::iterator
Member types
Mitglied Typ
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 |
[Bearbeiten] Beispiel
#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, " ")); }
Output:
0.1 0.3 0.6 1
[Bearbeiten] Siehe auch
Ausgabeiterator, die std::basic_streambuf schreibt 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. (Klassen-Template) | |
Input-Iterator, die aus std::basic_istream liest 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. (Klassen-Template) |