std::move_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 Iterator> class move_iterator | (dal C++11) | |
std::move_iterator
iteratore è un adattatore che si comporta esattamente come l'iteratore di fondo (che deve essere almeno un InputIterator
), tranne che dereferenziazione converte il valore restituito dalla iteratore sottostante in un rvalue. Se questo iteratore viene utilizzato come un iteratore di input, l'effetto è che i valori vengono spostati da, anziché copiato da.Original:
std::move_iterator
is an iterator adaptor which behaves exactly like the underlying iterator (which must be at least an InputIterator
), except that dereferencing converts the value returned by the underlying iterator into an rvalue. If this iterator is used as an input iterator, the effect is that the values are moved from, rather than copied from.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 |
iterator_type | Iterator |
difference_type | std::iterator_traits<Iterator>::difference_type |
pointer | Iterator |
value_type | std::iterator_traits<Iterator>::value_type |
iterator_category | std::iterator_traits<Iterator>::iterator_category |
reference | value_type&& |
[modifica]Membri funzioni
costruisce un nuovo adattatore iteratore Original: constructs a new iterator adaptor The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (metodo pubblico) | |
assegna un altro iteratore Original: assigns another 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) | |
accede l'iteratore sottostante Original: accesses the underlying 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) | |
accede alla punta-all'elemento Original: accesses the pointed-to 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) | |
ottiene rvalue riferimento all'elemento indicizzati Original: obtains rvalue reference to indexed 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) | |
anticipi o decrementa l'iteratore Original: advances or decrements the 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 i iteratori sottostanti Original: compares the underlying 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) | |
avanza l'iteratore Original: advances the iterator 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) | |
calcola la distanza tra due schede di iteratore Original: computes the distance between two iterator adaptors 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) |
[modifica]Esempio
#include <iostream>#include <algorithm>#include <vector>#include <iterator>#include <numeric>int main(){std::vector<std::string> v{"this", "is", "an", "example"}; std::cout<<"Old contents of the vector: ";for(auto& s : v)std::cout<<'"'<< s <<"\" "; typedefstd::vector<std::string>::iterator iter_t;std::string concat =std::accumulate( std::move_iterator<iter_t>(v.begin()), std::move_iterator<iter_t>(v.end()), std::string());// Can be simplified with std::make_move_iterator std::cout<<"\nConcatenated as string: "<< concat <<'\n'<<"New contents of the vector: ";for(auto& s : v)std::cout<<'"'<< s <<"\" ";std::cout<<'\n';}
Output:
Old contents of the vector: "this" "is" "an" "example" Concatenated as string: thisisanexample New contents of the vector: "" "" "" ""
[modifica]Vedi anche
(C++11) | crea un std::move_iterator di tipo derivato dalla tesi Original: creates a std::move_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. (funzione di modello) |