std::istream_iterator
De 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. |
<metanoindex/>
<tbody> </tbody>| Dclar dans l'en-tte <iterator>
|
||
template< class T, class CharT = char, class Traits = std::char_traits<CharT>, class Distance = std::ptrdiff_t > class istream_iterator: public std::iterator<std::input_iterator_tag, T, Distance, const T*, const T&> |
||
std::istream_iterator est un itrateur d'entre en un seul passage qui lit les objets successifs de T Type de l'objet pour lequel std::basic_istream il a t construit, en appelant le operator>> appropri. L'opration de lecture relle est effectue lorsque l'itrateur est incrment, pas quand il est drfrenc. Le premier objet peut tre lu lorsque l'itrateur est construit ou lorsque le drfrencement premier pas est fait. Dans le cas contraire, le drfrencement ne renvoie une copie de l'objet le plus lu rcemment .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.
La valeur par dfaut construit
std::istream_iterator est connue comme la fin de flux itrateur. Quand un std::istream_iterator valide atteint la fin du flux sous-jacent, il devient gal l'itrateur de fin de courant. Drfrencement ou l'incrmentant invoque par ailleurs un comportement indfini .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.
Une implmentation typique de
std::istream_iterator est titulaire de deux membres de donnes: un pointeur sur l'objet std::basic_istream associ et la valeur la plus rcemment lue de type 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.
Lors de la lecture des caractres, std::istreambuf_iterator est plus efficace, car elle permet d'viter la surcharge de la construction et de dtruire l'objet sentinelle fois par personnage .
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.
Types de membres
| Type du membre | Dfinition |
char_type
|
CharT
|
traits_type
|
Traits
|
istream_type
|
std::basic_istream<CharT, Traits>
|
Fonctions membres
construit un nouveau 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. (fonction membre publique) | |
(destructeur) (implicitement dclar) |
destructs an istream_iterator, including the cached value (fonction membre publique) |
obtient une copie du courant element accesses un lment de l'lment courant 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. (fonction membre publique) | |
les progrs de la 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. (fonction membre publique) | |
Fonctions annexes
compare deux 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. (fonction gnrique) | |
Inherited from std::iterator
Member types
| Type du membre | Dfinition |
value_type
|
T
|
difference_type
|
Distance
|
pointer
|
const T*
|
reference
|
const T&
|
iterator_category
|
std::input_iterator_tag
|
Exemple
#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, " "));
}
Rsultat :
0.1 0.3 0.6 1
Voir aussi
itrateur de sortie qui crit dans 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 gnrique) | |
itrateur d'entre qui lit 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 gnrique) | |