iter_move (std::move_iterator)
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
|
(until C++20)
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
iter_move
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++11)
|
|
friend
constexpr
std::
iter_rvalue_reference_t
<
Iter
>
iter_move ( const std:: move_iterator & i ) noexcept ( /* see below */ ) ; |
(C++20 起) | |
将底层迭代器解引用的结果转换为其关联的右值引用类型。
等价于 return std :: ranges:: iter_move ( i. base ( ) ) ; 。
此函数模板对普通的 非限定查找 或 限定查找 不可见,仅当 std:: move_iterator < Iter > 作为参数的关联类时,才能通过 实参依赖查找 被找到。
目录 |
参数
| i | - | 源移动迭代器 |
返回值
右值引用或纯右值临时对象。
复杂度
常量。
异常
示例
#include <iomanip> #include <iostream> #include <iterator> #include <string> #include <vector> void print(const auto& rem, const auto& v) { std::cout << rem << '[' << size(v) << "] { "; for (char comma[]{0, ' ', 0}; const auto& s : v) std::cout << comma << std::quoted(s), comma[0] = ','; std::cout << " }\n"; } int main() { std::vector<std::string> p{"Andromeda", "Cassiopeia", "Phoenix"}, q; print("p", p), print("q", q); using MI = std::move_iterator<std::vector<std::string>::iterator>; for (MI first{p.begin()}, last{p.end()}; first != last; ++first) q.emplace_back(/* ADL */ iter_move(first)); print("p", p), print("q", q); }
可能的输出:
p[3] { "Andromeda", "Cassiopeia", "Phoenix" }
q[0] { }
p[3] { "", "", "" }
q[3] { "Andromeda", "Cassiopeia", "Phoenix" }
参见
|
(C++20)
|
将对对象解引用的结果转换为其关联的右值引用类型
(定制点对象) |
|
(C++20)
|
将对调整后的底层迭代器解引用的结果转换为其关联的右值引用类型
(函数) |
|
(C++11)
|
将参数转换为亡值
(函数模板) |
|
(C++11)
|
若移动构造函数不抛出异常则将参数转换为亡值
(函数模板) |
|
(C++11)
|
转发函数参数并使用类型模板形参保持其值类别
(函数模板) |
|
(C++20)
|
将元素范围移动到新位置
(算法函数对象) |
|
(C++20)
|
以逆序将元素范围移动到新位置
(算法函数对象) |