◐ Shell
clean mode source ↗

std::move_iterator – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

definiert in Header

<iterator>

template <class Iterator> class move_iterator

(seit C++11)

std::move_iterator ist ein Iterator-Adapter, der genau wie die zugrundeliegenden Iterator (welche mindestens eine InputIterator sein) verhält, wobei jedoch Dereferenzierung wandelt den Wert des zugrundeliegenden Iterator in einen R-Wert zurückgeführt. Wenn dies Iterator als Eingang Iterator verwendet wird, ist der Effekt, dass die Werte aus bewegt werden, anstatt kopiert .

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.

Mitglied Typen

Mitglied Typ

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&&

Member-Funktionen

baut einen neuen Iterator-Adapter

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.


(öffentliche Elementfunktion) [edit]

ordnet eine andere Iterator

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.


(öffentliche Elementfunktion) [edit]

greift auf die zugrunde liegenden Iterator

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.


(öffentliche Elementfunktion) [edit]

greift auf die spitzen-to-Element

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.


(öffentliche Elementfunktion) [edit]

erhält rvalue Bezug auf indizierte Element

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.


(öffentliche Elementfunktion) [edit]

Vorschüsse oder dekrementiert den Iterator

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.


(öffentliche Elementfunktion) [edit]

Non-Member-Funktionen

vergleicht die zugrunde liegenden Iteratoren

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.


(Funktions-Template) [edit]

Fortschritte der Iterator

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.


(Funktions-Template) [edit]

berechnet den Abstand zwischen zwei Iterator Adaptern

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.


(Funktions-Template) [edit]

Beispiel

#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';
}

Output:

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

Siehe auch

schafft eine std::move_iterator des Typs aus dem Argument abgeleitet

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.


(Funktions-Template) [edit]