Namespaces
Variants

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

ja.cppreference.net より

 
 
 
 
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 の最初の要素の前の要素に対応します。この要素はプレースホルダとして機能し、それにアクセスしようとすると未定義動作となります。

戻り値

最後の要素の次の要素への逆イテレータ。

計算量

定数。

例

#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};
    // const_reverse_iteratorを使用してコンテナの要素を逆順に出力
    std::for_each(a.crbegin(), a.crend(), [](int e){ std::cout << e << ' '; });
    std::cout << '\n';
    // 非const reverse_iteratorを使用してコンテナの各要素を変更
    std::for_each(a.rbegin(), a.rend(), [](int& e){ e += 32; });
    // const_reverse_iteratorを使用して文字として要素を逆順に出力
    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)
(C++14)
コンテナまたは配列の終端を指す逆方向イテレータを返す
(function template)