Namensräume
Varianten
Aktionen

std::move

Aus cppreference.com
< cpp‎ | algorithm

 
 
Algorithm Bibliothek
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Nicht-modifizierende Sequenz Operationen
Original:
Non-modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modifizierende Sequenz Operationen
Original:
Modifying sequence operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Partitionierungsoperationen
Original:
Partitioning operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Sortierung Operationen (auf sortierten Bereiche)
Original:
Sorting operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Binary Suchaktionen (auf sortierten Bereiche)
Original:
Binary search operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Set-Operationen (auf sortierten Bereiche)
Original:
Set operations (on sorted ranges)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Heap-Operationen
Original:
Heap operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Minimum / Maximum Operationen
Original:
Minimum/maximum operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Numerische Operationen
Original:
Numeric operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
C-Bibliothek
Original:
C library
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Defined in header <algorithm>
template< class InputIt, class OutputIt >
OutputIt move( InputIt first, InputIt last, OutputIt d_first );
(seit C++11)
Verschiebt die Elemente im Bereich [first, last), in einen anderen Bereich beginnend bei d_first. Nach dieser Operation werden die Elemente in der eingefahrenen vom Bereich noch gültige Werte enthalten des entsprechenden Typs, aber nicht unbedingt die gleichen Werte wie vor dem Umzug .
Original:
Moves the elements in the range [first, last), to another range beginning at d_first. After this operation the elements in the moved-from range will still contain valid values of the appropriate type, but not necessarily the same values as before the move.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Inhaltsverzeichnis

[Bearbeiten] Parameter

first, last -
das Spektrum der Elemente zu bewegen
Original:
the range of elements to move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
d_first -
der Beginn des Zielbereichs. Wenn d_first in [first, last) ist, muss std::move_backward statt NJ std :: move </ span> verwendet werden .
Original:
the beginning of the destination range. If d_first is within [first, last), std::move_backward must be used instead of NJ std :: move </ span>. </div>
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
</div></div></div></div>
Type requirements
-
InputIt must meet the requirements of InputIterator.
-
OutputIt must meet the requirements of OutputIterator.

[Bearbeiten] Rückgabewert

Ausgabeiterator auf das Element nach dem letzten Element bewegt (d_first + (last - first))
Original:
Output iterator to the element past the last element moved (d_first + (last - first))
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Komplexität

Genau last - first bewegen Aufgaben .
Original:
Exactly last - first move assignments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Mögliche Implementierung

template<class InputIt, class OutputIt>
OutputIt move(InputIt first, InputIt last, 
                    OutputIt d_first)
{
    while (first != last) {
        *d_first++ = std::move(*first++);
    }
    return d_first;
}

[Bearbeiten] Beispiel

Der folgende Code bewegt Thread-Objekte (die selbst nicht kopierbar) von einem Behälter in einen anderen. </ p>

Original:
<p>The following code moves thread objects (which themselves are not copyable) from one container to another.</p>
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
</div>

#include <iostream>
#include <vector>
#include <list>
#include <iterator>
#include <thread>
#include <chrono>

void f(int n)
{
    std::this_thread::sleep_for(std::chrono::seconds(n));
    std::cout << "thread " << n << " ended" << '\n';
}

int main()
{
    std::vector<std::thread> v;
    v.emplace_back(f, 1);
    v.emplace_back(f, 2);
    v.emplace_back(f, 3);
    std::list<std::thread> l;
    // copy() would not compile, because std::thread is noncopyable
std :: move </ span>(v.begin(), v.end(), std::back_inserter(l));
    for(auto& t : l) t.join();
}
</div>

Output:
Original:
Output:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
thread 1 ended
thread 2 ended
thread 3 ended

[Bearbeiten] Siehe auch

bewegt sich eine Reihe von Elementen, um einen neuen Standort in rückwärts um
Original:
moves a range of elements to a new location in backwards order
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]

Von „http://de.cppreference.com/mwiki/index.php?title=cpp/algorithm/move&oldid=26098