std::istream_iterator
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Elemento definito nell'header <iterator> | ||
template<class T, class CharT =char, | ||
std::istream_iterator
è un passaggio singolo iteratore di input che legge gli oggetti successivi di tipo T
dall'oggetto std::basic_istream per cui è stata costruita, chiamando il operator>>
appropriato. L'operazione di lettura reale viene eseguita quando l'iteratore non viene incrementato, quando è dereferenziato. Il primo oggetto può essere letto quando l'iteratore è costruito o quando la dereferenziazione primo fatto. In caso contrario, dereferenziare solo restituisce una copia dell'oggetto più letto di recente.Original:
std::istream_iterator
is a single-pass input iterator that reads successive objects of type T
from the std::basic_istream object for which it was constructed, by calling the appropriate operator>>
. The actual read operation is performed when the iterator is incremented, not when it is dereferenced. The first object may be read when the iterator is constructed or when the first dereferencing is done. Otherwise, dereferencing only returns a copy of the most recently read object.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.
L'impostazione predefinita-costruito
std::istream_iterator
è conosciuta come la fine flusso di iteratore. Quando un std::istream_iterator
valida raggiunge la fine del flusso sottostante, diventa uguale al fine flusso iteratore. Dereferenziazione o incrementarlo richiede ulteriori comportamento indefinito.Original:
The default-constructed
std::istream_iterator
is known as the end-of-stream iterator. When a valid std::istream_iterator
reaches the end of the underlying stream, it becomes equal to the end-of-stream iterator. Dereferencing or incrementing it further invokes undefined behavior.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.
Una tipica implementazione di
std::istream_iterator
tiene due membri di dati: un puntatore all'oggetto std::basic_istream associato e il valore più letto di recente di tipo T
.Original:
A typical implementation of
std::istream_iterator
holds two data members: a pointer to the associated std::basic_istream object and the most recently read value of type T
.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.
Durante la lettura di caratteri, std::istreambuf_iterator è più efficiente, dato che evita il sovraccarico di costruire e distruggendo l'oggetto sentinella una volta per carattere.
Original:
When reading characters, std::istreambuf_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.
Indice |
[modifica]Membri tipi
Membro 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 |
istream_type | std::basic_istream<CharT, Traits> |
[modifica]Membri funzioni
costruisce un nuovo istream_iterator Original: constructs a new istream_iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
(destructor) (dichiarato in modo implicito) | destructs an istream_iterator, including the cached value (metodo pubblico) |
ottiene una copia della corrente element accesses membro dell'elemento corrente Original: obtains a copy of the current element accesses a member of the current element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
fa avanzare il istream_iterator Original: advances the istream_iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) |
[modifica]Non membri funzioni
confronta due istream_iterators Original: compares two istream_iterators The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (funzione di modello) |
Inherited from std::iterator
Member types
Membro 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 | T |
difference_type | Distance |
pointer | const T* |
reference | const T& |
iterator_category | std::input_iterator_tag |
[modifica]Esempio
#include <iostream>#include <sstream>#include <iterator>#include <numeric> 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
[modifica]Vedi anche
uscita iteratore che scrive std::basic_ostream Original: output iterator that writes to std::basic_ostream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (classe template) | |
iteratore di input che legge da std::basic_streambuf Original: input iterator that reads from 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. (classe template) |