The Wayback Machine - https://web.archive.org/web/20180525152602/http://pt.cppreference.com:80/w/cpp/algorithm/move
Espaços nominais
Variantes
Acções

std::move

Da cppreference.com
< cpp‎ | algorithm

 
 
Biblioteca algoritmo
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Não modificar operações de seqüência
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.
Modificando operações de seqüência
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.
Particionamento operações
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.
Operações de classificação (em intervalos ordenados)
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.
Binários operações de busca (em intervalos ordenados)
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.
Definir operações (em intervalos ordenados)
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.
Operações de pilha
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.
Mínimo / máximo de operações
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.
Operações numéricas
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 biblioteca
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 );
(a partir do C++ 11)
Move os elementos no [first, last) gama, para um outro intervalo de início d_first. Após esta operação os elementos no intervalo mudou-do ainda irá conter valores válidos do tipo apropriado, mas não necessariamente os mesmos valores de antes da mudança.
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.

Índice

[editar]Parâmetros

first, last -
a gama de elementos para se mover
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 -
o início do intervalo de destino. Se d_first está dentro [first, last), std::move_backward deve ser utilizado em vez de NJ std :: movimento </ span> .
Original:
the beginning of the destination range. If d_first is within [first, last), std::move_backward must be used instead of NJ std :: movimento </ 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.

[editar]Valor de retorno

Iterador de saída para o elemento passado o último elemento movido (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.

[editar]Complexidade

Exatamente last - first mover atribuições.
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.

[editar]Possível implementação

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

[editar]Exemplo

O código a seguir move objetos de rosca (que em si não são copiável) de um recipiente para outro. </ 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 :: movimento </ span>(v.begin(), v.end(), std::back_inserter(l));
    for(auto& t : l) t.join();
}
</div>

Saída:
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

[editar]Veja também

move uma série de elementos para uma nova localização para trás
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.

(modelo de função)[edit]

Obtida de "http://pt.cppreference.com/mwiki/index.php?title=cpp/algorithm/move&oldid=19943"
close