std::back_insert_iterator
Da 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. |
Definido no cabeçalho <iterator>
|
||
template< class Container > class back_insert_iterator : public std::iterator< std::output_iterator_tag, |
||
std::back_insert_iterator
é um OutputIterator
que acrescenta a um recipiente para o qual foi construído, utilizando a função do recipiente membro push_back()
sempre que o iterador (se dereferenced ou não) é atribuído. Incrementando a std::back_insert_iterator
é um não-op.Original:
std::back_insert_iterator
is an OutputIterator
that appends to a container for which it was constructed, using the container's push_back()
member function whenever the iterator (whether dereferenced or not) is assigned to. Incrementing the std::back_insert_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.
Í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 |
container_type
|
Container
|
[editar] Funções de membro
Predefinição:cpp/iterator/inserter/dsc operator++ constrói um novo back_insert_iterator Original: constructs a new back_insert_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) | |
insere um objecto para o recipiente associado Original: inserts an object into the associated container 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) | |
no-op (função pública membro) |
[editar] Objetos Membros
Nome do membro
Original: Member name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
container (protegido)
|
um ponteiro de
Container* tipo Original: a pointer of type Container* The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Herdado de 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
|
void |
difference_type
|
void |
pointer
|
void |
reference
|
void |
iterator_category
|
std::output_iterator_tag |
[editar] Exemplo
#include <iostream> #include <iterator> #include <algorithm> #include <cstdlib> int main() { std::vector<int> v; std::generate_n(std::back_insert_iterator<std::vector<int>>(v), // can be simplified 10, [](){return std::rand()%10;}); // with std::back_inserter for(int n : v) std::cout << n << ' '; std::cout << '\n'; }
Saída:
3 6 7 5 3 5 6 2 9 1
[editar] Veja também
cria um std::back_insert_iterator do tipo inferido a partir do argumento Original: creates a std::back_insert_iterator of type inferred from the argument 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) | |
adaptador iterador para inserção na parte da frente de um recipiente Original: iterator adaptor for insertion at the front of a container 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) | |
adaptador iterador para inserção dentro de um recipiente Original: iterator adaptor for insertion into a container 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) |