Espaços nominais
Variantes
Acções

std::istream_iterator

Da cppreference.com
< cpp‎ | iterator

 
 
Biblioteca Iterator
Primitivas iterador
Original:
Iterator primitives
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iterator_traits
input_iterator_tag
output_iterator_tag
forward_iterator_tag
bidirectional_iterator_tag
random_access_iterator_tag
iterator
Adaptadores de iterador
Original:
Iterator adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reverse_iterator
Iteradores fluxo
Original:
Stream iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istream_iterator
ostream_iterator
istreambuf_iterator
ostreambuf_iterator
Operações iterador
Original:
Iterator operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
advance
distance
prev(C++11)
next(C++11)
Variar de acesso
Original:
Range access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
begin(C++11)
end(C++11)
 
std::istream_iterator
Funções de membro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istream_iterator::istream_iterator
istream_iterator::operator*
istream_iterator::operator->
istream_iterator::operator++
istream_iterator::operator++(int)
Não-membros funções
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator==
operator!=
 
Defined in header <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 é um iterador de entrada única passagem que se lê objetos sucessivos de T tipo do objeto std::basic_istream para o qual foi construído, chamando o operator>> apropriado. A operação de leitura actual é executada quando o iterador é incrementado, e não quando é dereferenced. O primeiro objeto pode ser lido quando o iterador é construído ou quando o dereferencing primeiro é feito. Caso contrário, dereferencing só retorna uma cópia do objeto mais recentemente li.
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.
O padrão construído std::istream_iterator é conhecido como o fim-de-fluxo iterador. Quando um std::istream_iterator válido atinge o final do fluxo de base, torna-se igual ao iterador fim-de-fluxo. Dereferencing ou incrementá-lo ainda mais invoca comportamento indefinido.
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.
Uma implementação típica de std::istream_iterator detém dois membros de dados: um ponteiro para o objeto associado e std::basic_istream o valor mais recentemente lido do 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.
Ao ler caracteres, std::istreambuf_iterator é mais eficiente, uma vez que evita a sobrecarga de construção e destruindo o objeto sentinela uma vez por personagem.
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.

Í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
istream_type std::basic_istream<CharT, Traits>

[editar] Funções de membro

constrói um novo 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.

(função pública membro)
(destructor)
(declarada implicitamente)
destructs an istream_iterator, including the cached value
(função pública membro)
obtém uma cópia do atual element
accesses um membro do elemento atual
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.

(função pública membro)
avança a 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.

(função pública membro)

[editar] Não-membros funções

compara dois 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.

(modelo de função)

Inherited from 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 T
difference_type Distance
pointer const T*
reference const T&
iterator_category std::input_iterator_tag

[editar] Exemplo

#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

[editar] Veja também

iterador de saída que escreve para 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.

(modelo de classe) [edit]
iterador de entrada que lê 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.

(modelo de classe) [edit]