std:: iter_move (std::reverse_iterator)
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||
| Non-member functions | ||||
|
iter_move
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++14)
|
|
friend
constexpr
std::
iter_rvalue_reference_t
<
Iter
>
iter_move ( const std:: reverse_iterator & i ) noexcept ( /* 见下文 */ ) ; |
(C++20 起) | |
将解引用调整后的底层迭代器的结果转换为其关联的右值引用类型。
等价于
auto
tmp
=
i.
base
(
)
;
return
std
::
ranges::
iter_move
(
--
tmp
)
;
。
此函数模板对普通的 非限定查找 或 限定查找 不可见,仅当 std:: reverse_iterator < Iter > 作为参数的关联类时,才能通过 实参依赖查找 找到。
目录 |
参数
| i | - | 源反向迭代器 |
返回值
右值引用或纯右值临时对象。
复杂度
常量。
异常
std::
is_nothrow_copy_constructible_v
<
Iter
>
&&
noexcept
(
std
::
ranges::
iter_move
(
--
std::
declval
<
Iter
&
>
(
)
)
示例
#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{"Alpha", "Bravo", "Charlie"}, q; print("p", p), print("q", q); using RI = std::reverse_iterator<std::vector<std::string>::iterator>; for (RI iter{p.rbegin()}, rend{p.rend()}; iter != rend; ++ iter) q.emplace_back(/* ADL */ iter_move(iter)); print("p", p), print("q", q); }
可能的输出:
p[3] { "Alpha", "Bravo", "Charlie" }
q[0] { }
p[3] { "", "", "" }
q[3] { "Charlie", "Bravo", "Alpha" }
参见
|
(C++20)
|
将对对象解引用的结果转换为其关联的右值引用类型
(定制点对象) |
|
(C++20)
|
将底层迭代器解引用的结果转换为其关联的右值引用类型
(函数) |
|
(C++11)
|
将参数转换为亡值
(函数模板) |
|
(C++11)
|
若移动构造函数不抛出异常则将参数转换为亡值
(函数模板) |
|
(C++11)
|
转发函数实参并利用模板形参类型保持其值类别
(函数模板) |
|
(C++20)
|
将元素范围移动到新位置
(算法函数对象) |
|
(C++20)
|
以逆序将元素范围移动到新位置
(算法函数对象) |