std::inplace_vector<T,N>::rbegin, std::inplace_vector<T,N>::crbegin
ja.cppreference.net から
constexpr reverse_iterator rbegin() noexcept;
|
(1) | (since C++26) |
constexpr const_reverse_iterator rbegin() const noexcept;
|
(2) | (since C++26) |
constexpr const_reverse_iterator crbegin() const noexcept;
|
(3) | (since C++26) |
反転されたinplace_vectorの最初の要素への逆イテレータを返します。これは、反転されていないinplace_vectorの最後の要素に対応します。inplace_vectorが空の場合、返されるイテレータはrend()と等しくなります。
戻り値
最初の要素への逆方向イテレータ。
計算量
定数。
注記
返される逆イテレータの 基盤イテレータ は 終端イテレータ です。したがって、終端イテレータが無効化された場合、返されるイテレータも無効化されます。
例
このコードを実行する
#include <algorithm>
#include <iostream>
#include <string>
#include <string_view>
#include <inplace_vector>
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 member function) |
|
|
(C++14)
|
コンテナまたは配列の先頭を指す逆イテレータを返す
(function template) |