◐ Shell
clean mode source ↗

std::move_iterator — cppreference.com

De cppreference.com

<metanoindex/>

<tbody> </tbody>

Déclaré dans l'en-tête

<iterator>

template <class Iterator> class move_iterator

(depuis C++11)

std::move_iterator est un adaptateur itérateur qui se comporte exactement comme l'itérateur sous-jacente (qui doit être d'au moins un InputIterator), sauf que le déréférencement convertit la valeur retournée par l'itérateur sous-jacent dans une rvalue. Si cet itérateur est utilisé comme un itérateur d'entrée, l'effet est que les valeurs sont déplacés d', plutôt que de copier de .

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.

Types de membres

Type du membre Définition
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&&

Fonctions membres

construit un nouvel itérateur adaptateur

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.


(fonction membre publique) [edit]

assigne un autre itérateur

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.


(fonction membre publique) [edit]

accède à l'itérateur sous-jacent

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.


(fonction membre publique) [edit]

accède à l'élément pointé vers

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.


(fonction membre publique) [edit]

obtient de référence rvalue à l'élément indexé

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.


(fonction membre publique) [edit]

avances ou décrémente l'itérateur

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.


(fonction membre publique) [edit]

Fonctions annexes

compare les itérateurs sous-jacents

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.


(fonction générique) [edit]

progrès de l'itérateur

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.


(fonction générique) [edit]

calcule la distance entre deux adaptateurs itérateur

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.


(fonction générique) [edit]

Exemple

#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 << "\" ";

    typedef std::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';
}

Résultat :

Old contents of the vector: "this" "is" "an" "example"
Concatenated as string: thisisanexample
New contents of the vector: "" "" "" ""

Voir aussi

crée un std::move_iterator de type inféré à partir de l'argument

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.


(fonction générique) [edit]