std::span<T,Extent>::rbegin, std::span<T,Extent>::crbegin
From cppreference.com
| constexpr reverse_iterator rbegin() const noexcept; |
(1) | (C++20以降) |
| constexpr const_reverse_iterator crbegin() const noexcept; |
(2) | (C++23から) |
逆順にされたspanの最初の要素へのリバースイテレータを返します。これは、逆順にされていないspanの最後の要素に対応します。spanが空の場合、返されるイテレータはrend()と等しくなります。
目次 |
[編集] 戻り値
最初の要素へのリバースイテレータ。
[編集] 計算量
定数。
[編集] 注記
返されたリバースイテレータの基になるイテレータは、endイテレータです。したがって、endイテレータが無効になった場合に、返されたイテレータも無効になります。
[編集] 例
このコードを実行
#include <algorithm> #include <iostream> #include <iterator> #include <span> int main() { constexpr std::span<const char> code{"@droNE_T0P_w$s@s#_SECRET_a,p^42!"}; auto hack = [](const unsigned O) { return O - 0141 < 120; }; std::copy_if(code.rbegin(), code.rend(), std::ostream_iterator<const char>(std::cout), hack); std::cout << '\n'; }
出力
password
[編集] 関連項目
| (C++23) |
末尾への逆イテレータを返す (public メンバ関数) |
| (C++14) |
コンテナまたは配列の先頭を指す逆順イテレータを返す (function template) |