The Wayback Machine - https://web.archive.org/web/20161016152640/http://ja.cppreference.com:80/w/cpp/algorithm/move
名前空間
変種
操作

std::move

提供: cppreference.com
< cpp‎ | algorithm

 
 
アルゴリズムライブラリ
機能します
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
シーケンス動作を非改変
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.
シーケンス動作を変更する
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.
操作を仕切る
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.
(ソートされた範囲で)ソート操作
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.
バイナリ検索操作(ソート範囲で)
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.
(ソートされた範囲で)操作を設定します
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.
ヒープ操作
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.
最小値/最大値操作
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.
数値演算
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ライブラリ
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 );
(C++11およびそれ以降)
[first, last)で別の範囲の先頭に、範囲d_first内の要素を移動します。この操作の後に移動し、範囲内の要素は、依然として適切な型の有効な値が含まれていますが、移動前と同じ値であるとは限らないでしょう.
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.

目次

[編集]パラメータ

first, last -
移動する要素の範囲
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 -
目的の範囲の始まり。 d_first[first, last)内であれば、std::move_backwardNJのstd ::移動</ 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 ::移動</ 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>
型の要件
-
InputItInputIterator

の要求を満足しなければなりません。

-
OutputItOutputIterator

の要求を満足しなければなりません。

[編集]値を返します

最後の要素は、過去の要素への出力イテレータは(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.

[編集]複雑性

まさにlast - first割り当てを移動.
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.

[編集]可能な実装

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

[編集]

次のコードは、別のコンテナからスレッドオブジェクトを(それ自体がコピーではない)に移動します</ 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 ::移動</ span>を(v.begin(), v.end(), std::back_inserter(l));
    for(auto& t : l) t.join();
}
</div>

出力:
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

[編集]参照

下位の順序で新しい場所に要素の範囲を移動します
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.

(関数テンプレート)[edit]

http://ja.cppreference.com/mwiki/index.php?title=cpp/algorithm/move&oldid=29125」から取得
close