std:: make_move_iterator
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<iterator>
|
||
|
template
<
class
Iter
>
std:: move_iterator < Iter > make_move_iterator ( Iter i ) ; |
(C++11以降)
(constexpr C++17以降) |
|
make_move_iterator
は、指定されたイテレータ
i
に対して、引数の型から推論された型で
std::move_iterator
を構築する便利な関数テンプレートです。
目次 |
パラメータ
| i | - | ムーブイテレータに変換する入力イテレータ |
戻り値
std:: move_iterator < Iter > ( std :: move ( i ) )
例
#include <iomanip> #include <iostream> #include <iterator> #include <list> #include <string> #include <vector> auto print = [](const auto rem, const auto& seq) { for (std::cout << rem; const auto& str : seq) std::cout << std::quoted(str) << ' '; std::cout << '\n'; }; int main() { std::list<std::string> s{"one", "two", "three"}; std::vector<std::string> v1(s.begin(), s.end()); // コピー std::vector<std::string> v2(std::make_move_iterator(s.begin()), std::make_move_iterator(s.end())); // ムーブ print("v1 now holds: ", v1); print("v2 now holds: ", v2); print("original list now holds: ", s); }
出力例:
v1 now holds: "one" "two" "three" v2 now holds: "one" "two" "three" original list now holds: "" "" ""
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 2061 | C++11 |
make_move_iterator
は配列引数をポインタに変換しなかった
|
変換するように変更 |
関連項目
|
(C++11)
|
右辺値にデリファレンスするイテレータアダプタ
(クラステンプレート) |
|
(C++11)
|
引数をxvalueに変換する
(関数テンプレート) |