名前空間
変種
操作

std::inplace_vector<T,N>::rbegin, std::inplace_vector<T,N>::crbegin

From cppreference.com
 
 
 
 
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()と等しくなります。

range-rbegin-rend.svg

目次

[編集] 戻り値

最初の要素へのリバースイテレータ。

[編集] 計算量

定数。

[編集] 注記

返されるリバースイテレータの基底イテレータは、endイテレータです。したがって、endイテレータが無効になった時点で、返されるイテレータも無効になります。

[編集]

#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("Print 'arr' in direct order using [cbegin, cend):\t");
    std::for_each(arr.cbegin(), arr.cend(), print);
 
    print("\n\nPrint 'arr' in reverse order using [crbegin, crend):\t");
    std::for_each(arr.crbegin(), arr.crend(), print);
}

出力

Print 'arr' in direct order using [cbegin, cend):        ▁ ▂ ▃ ▄ ▅ ▆ ▇ █
 
Print 'arr' in reverse order using [crbegin, crend):     █ ▇ ▆ ▅ ▄ ▃ ▂ ▁

[編集] 関連項目

末尾への逆イテレータを返す
(public メンバ関数) [編集]
コンテナまたは配列の先頭を指す逆順イテレータを返す
(function template) [編集]
English 日本語 中文(简体) 中文(繁體)