std::inplace_vector<T,N>::rbegin, std::inplace_vector<T,N>::crbegin
来自cppreference.com
<tbody>
</tbody>
constexpr reverse_iterator rbegin() noexcept; |
(1) | (C++26 起) |
constexpr const_reverse_iterator rbegin() const noexcept; |
(2) | (C++26 起) |
constexpr const_reverse_iterator crbegin() const noexcept; |
(3) | (C++26 起) |
返回指向逆向的 inplace_vector 的首元素的逆向迭代器。它对应非逆向 inplace_vector 的末元素。如果 inplace_vector 为空,那么返回的迭代器等于 rend()。
返回值
指向首元素的逆向迭代器。
复杂度
常数。
注解
返回的逆向迭代器的底层迭代器是尾迭代器。因此在尾迭代器失效时,返回的迭代器也会失效。
示例
运行此代码
#include <algorithm>
#include <inplace_vector>
#include <iostream>
#include <string>
#include <string_view>
void print(const std::string_view s) { std::cout << s << ' '; }
int main()
{
const std::inplace_vector<std::string_view, 8> data
{
"▁","▂","▃","▄","▅","▆","▇","█"
};
std::inplace_vector<std::string, 8> arr(8);
std::copy(data.cbegin(), data.cend(), arr.begin());
print("用 [cbegin, cend) 以正序打印 'arr':\t");
std::for_each(arr.cbegin(), arr.cend(), print);
print("\n\n用 [crbegin, crend) 以逆序打印 'arr':\t");
std::for_each(arr.crbegin(), arr.crend(), print);
}
输出:
用 [cbegin, cend) 以正序打印 'arr': ▁ ▂ ▃ ▄ ▅ ▆ ▇ █
用 [crbegin, crend) 以逆序打印 'arr': █ ▇ ▆ ▅ ▄ ▃ ▂ ▁
参阅
| 返回指向末尾的逆向迭代器 (公开成员函数) | |
(C++14) |
返回指向一个容器或数组的逆向迭代器 (函数模板) |