std::array<T,N>:: rbegin, std::array<T,N>:: crbegin
From cppreference.net
|
reverse_iterator rbegin
(
)
noexcept
;
|
(1) |
(C++11以降)
(C++17以降 constexpr) |
|
const_reverse_iterator rbegin
(
)
const
noexcept
;
|
(2) |
(C++11以降)
(C++17以降 constexpr) |
|
const_reverse_iterator crbegin
(
)
const
noexcept
;
|
(3) |
(C++11以降)
(C++17以降 constexpr) |
反転された * this の最初の要素を指す逆方向イテレータを返します。これは非反転 * this の最後の要素に対応します。
* this が空の場合、返されるイテレータは rend() と等しくなります。
目次 |
戻り値
最初の要素への逆イテレータ。
計算量
定数。
注記
返される逆イテレータの 基盤となるイテレータ は 終端イテレータ です。したがって、終端イテレータが無効化された場合、返されるイテレータも無効化されます。
例
このコードを実行
#include <algorithm> #include <array> #include <iostream> #include <string> #include <string_view> void print(const std::string_view s) { std::cout << s << ' '; } int main() { const std::array<std::string_view, 8> data { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; std::array<std::string, 8> arr; 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) |