名稱空間
變體
操作

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

來自 cppreference.com
 
 
 
 
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]