命名空间
变体
操作

std::inplace_vector<T,N>::rend, std::inplace_vector<T,N>::crend

来自 cppreference.cn
 
 
 
 
constexpr reverse_iterator rend() noexcept;
(1) (C++26 起)
constexpr const_reverse_iterator rend() const noexcept;
(2) (C++26 起)
constexpr const_reverse_iterator crend() const noexcept;
(3) (C++26 起)

返回一个反向迭代器,指向反向 inplace_vector 的最后一个元素之后的位置。它对应于非反向 inplace_vector 的第一个元素之前的位置。此元素作为占位符,尝试访问它会导致未定义行为。

range-rbegin-rend.svg

目录

[编辑] 返回值

指向最后一个元素之后位置的逆向迭代器。

[编辑] 复杂度

常数时间。

[编辑] 示例

#include <algorithm>
#include <iostream>
#include <inplace_vector>
 
int main()
{
    std::inplace_vector<int, 11> a{1, 11, 11, 35, 0, 12, 79, 76, 76, 69, 40};
 
    // Print elements of container in reverse order using const_reverse_iterator's.
    std::for_each(a.crbegin(), a.crend(), [](int e){ std::cout << e << ' '; });
    std::cout << '\n';
 
    // Modify each element of container using non-const reverse_iterator's.
    std::for_each(a.rbegin(), a.rend(), [](int& e){ e += 32; });
 
    // Print elements as chars in reverse order using const_reverse_iterator's.
    std::for_each(a.crbegin(), a.crend(), [](char e){ std::cout << e; });
    std::cout << '\n';
}

输出

40 69 76 76 79 12 0 35 11 11 1
Hello, C++!

[编辑] 参阅

返回指向起始的逆向迭代器
(public member function) [edit]
(C++14)
返回容器或数组的反向结束迭代器
(function template) [edit]