std::make_move_iterator
Aus 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. |
definiert in Header <iterator>
|
||
template< class Iterator > std::move_iterator<Iterator> make_move_iterator( const Iterator& i ); |
(seit C++11) | |
make_move_iterator
ist eine Komfortfunktion Vorlage, die eine std::move_iterator für die gegebene Iterator i
mit dem Typ von der Art der Argumentation ableiten konstruiert .Original:
make_move_iterator
is a convenience function template that constructs a std::move_iterator for the given iterator i
with the type deduced from the type of the argument.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.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
i | - | Ein Iterator umgewandelt Iterator zu bewegen
Original: input iterator to be converted to move iterator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[Bearbeiten] Rückgabewert
A std::move_iterator die verwendet werden, um aus den Elementen durch
i
abgerufen verschoben werden kannOriginal:
A std::move_iterator which can be used to move from the elements accessed through
i
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.
[Bearbeiten] Mögliche Implementierung
template< class Iterator > std::move_iterator<Container> make_move_iterator( const Iterator& i) { return std::move_iterator<Iterator>(i); } |
[Bearbeiten] Beispiel
#include <iostream> #include <list> #include <vector> #include <string> #include <iterator> int main() { std::list<std::string> s{"one", "two", "three"}; std::vector<std::string> v1(s.begin(), s.end()); // copy std::vector<std::string> v2(std::make_move_iterator(s.begin()), std::make_move_iterator(s.end())); // move std::cout << "v1 now holds: "; for(auto str : v1) std::cout << "\"" << str << "\" "; std::cout << "\nv2 now holds: "; for(auto str : v2) std::cout << "\"" << str << "\" "; std::cout << "\noriginal list now holds: "; for(auto str : s) std::cout << "\"" << str << "\" "; std::cout << '\n'; }
Output:
v1 now holds: "one" "two" "three" v2 now holds: "one" "two" "three" original list now holds: "" "" ""
[Bearbeiten] Siehe auch
(C++11) |
Iterator-Adapter, der dereferenziert zu einem R-Wert auf Original: iterator adaptor which dereferences to an rvalue reference The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Klassen-Template) |
(C++11) |
erhält einen rvalue Referenz Original: obtains an rvalue reference The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (Funktions-Template) |