iter_move (std::common_iterator)
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
iter_move
(C++20)
|
||||
|
(C++20)
|
||||
| Helper classes | ||||
|
friend
constexpr
decltype
(
auto
)
iter_move
(
const
std::
common_iterator
&
i
)
noexcept
(
noexcept
(
ranges::
iter_move
(
std::
declval
<
const
I
&
>
(
)
)
)
|
(C++20 起) | |
将底层迭代器解引用的结果转换为其关联的右值引用类型。
函数体等价于: return std :: ranges:: iter_move ( std :: get < I > ( i. var ) ) ; 。
此函数对普通的 非限定查找 或 限定查找 不可见,仅当 std:: common_iterator < I, S > 作为参数的关联类时,才能通过 实参依赖查找 找到该函数。
如果
i.
var
不持有
I
对象(即迭代器),则行为未定义。
目录 |
参数
| i | - | 源迭代器适配器 |
返回值
右值引用或纯右值临时对象。
复杂度
常量。
示例
#include <iomanip> #include <iostream> #include <iterator> #include <string> #include <vector> void print(auto const& rem, auto const& v) { std::cout << rem << '[' << size(v) << "] { "; for (int o{}; auto const& s : v) std::cout << (o++ ? ", " : "") << std::quoted(s); std::cout << " }\n"; } int main() { std::vector<std::string> p{"Andromeda", "Cassiopeia", "Phoenix"}, q; print("p", p); print("q", q); using CTI = std::counted_iterator<std::vector<std::string>::iterator>; using CI = std::common_iterator<CTI, std::default_sentinel_t>; CI last{std::default_sentinel}; for (CI first{{p.begin(), 2}}; 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] { "", "", "Phoenix" }
q[2] { "Andromeda", "Cassiopeia" }
缺陷报告
下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。
| 缺陷报告 | 应用于 | 发布时行为 | 正确行为 |
|---|---|---|---|
| LWG 3953 | C++20 | 返回类型为 std:: iter_rvalue_reference_t < I > | 更改为 decltype ( auto ) |
参见
|
(C++20)
|
将对对象解引用的结果转换为其关联的右值引用类型
(定制点对象) |
|
(C++20)
|
将底层迭代器解引用的结果转换为其关联的右值引用类型
(函数) |
|
(C++11)
|
将参数转换为亡值
(函数模板) |
|
(C++11)
|
若移动构造函数不抛出异常则将参数转换为亡值
(函数模板) |
|
(C++11)
|
转发函数实参并利用模板形参类型保持其值类别
(函数模板) |
|
(C++20)
|
将元素范围移动到新位置
(算法函数对象) |
|
(C++20)
|
按逆序将元素范围移动到新位置
(算法函数对象) |