[ Web Proxy ]
URL:
Viewing: https://fr.cppreference.com/cpp/algorithm/move [Back]  [Original]

std::move cppreference.com
cppreference.com
Espaces de noms
Variantes

std::move

De cppreference.com

<metanoindex/>

 
 
Bibliothque d'algorithmes
Fonctions
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Non-modification de la squence des oprations
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.
Modification de la squence des oprations
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.
Des oprations de partitionnement
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.
Oprations de tri (sur les gammes tris)
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.
is_sorted (C++11)
is_sorted_until (C++11)
sort
Oprations binaires de recherche (sur les gammes tris)
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.
Dfinir les oprations (sur les gammes tris)
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.
Oprations Heap
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 de fonctionnement
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.
Oprations numriques
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.
Bibliothque C
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.
 
<tbody> </tbody>
Dclar dans l'en-tte <algorithm>
template< class InputIt, class OutputIt > OutputIt move( InputIt first, InputIt last, OutputIt d_first );
(depuis C++11)
Dplace les lments de la [first, last) gamme, un autre dbut de la plage d_first. Aprs cette opration, les lments de la gamme dplac-de contiendront toujours des valeurs valides du type appropri, mais pas ncessairement les mmes valeurs que avant le dmnagement .
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.

Paramtres

first, last -
la plage d'lments dplacer
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 -
le dbut de la plage de destination. Si d_first est dans [first, last), std::move_backward doit tre utilis la place de std :: move </ span> .
Original:
the beginning of the destination range. If d_first is within [first, last), std::move_backward must be used instead of std :: move </ span>.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Type requirements
-
InputIt must meet the requirements of InputIterator.
-
OutputIt must meet the requirements of OutputIterator.

Retourne la valeur

Itrateur de sortie de l'lment aprs le dernier lment dplac (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.

Complexit

Exactement last - first dplacer les affectations .
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.

Mise en uvre possible

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

Exemple

Le code suivant dplace des objets de fil (qui eux-mmes sont pas copiables) d'un rcipient un autre. </ p>

Original:

The following code moves thread objects (which themselves are not copyable) from one container to another.

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

#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

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

std :: move </ span>(v.begin(), v.end(), std::back_inserter(l)); for(auto& t : l) t.join(); }

Sortie:
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

Voir aussi

se dplace d'une gamme d'lments vers un nouvel emplacement dans l'ordre inverse
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.

(fonction gnrique) [edit]

Web Proxy Viewer  |  New URL  |  Original Page