std::list<T,Allocator>:: rend, std::list<T,Allocator>:: crend
From cppreference.net
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::list
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
reverse_iterator rend
(
)
;
|
(1) |
(C++11以降 noexcept)
(C++26以降 constexpr) |
|
const_reverse_iterator rend
(
)
const
;
|
(2) |
(C++11以降 noexcept)
(C++26以降 constexpr) |
|
const_reverse_iterator crend
(
)
const
noexcept
;
|
(3) |
(C++11以降)
(C++26以降 constexpr) |
反転された * this の最後の要素の次を指す逆方向イテレータを返します。これは、非反転 * this の最初の要素の前の要素に対応します。
この返されたイテレータはセンチネルとしてのみ機能します。これが デリファレンス可能 であることは保証されません。
目次 |
戻り値
最後の要素の次の要素への逆イテレータ。
計算量
定数。
注記
libc++はC++98モードに
crend()
をバックポートします。
例
このコードを実行
#include <algorithm> #include <iostream> #include <numeric> #include <string> #include <list> int main() { std::list<int> nums{1, 2, 4, 8, 16}; std::list<std::string> fruits{"orange", "apple", "raspberry"}; std::list<char> empty; // リストを表示 std::for_each(nums.rbegin(), nums.rend(), [](const int n) { std::cout << n << ' '; }); std::cout << '\n'; // リストnums内の全整数を合計し(存在する場合)、結果のみを表示 std::cout << "Sum of nums: " << std::accumulate(nums.rbegin(), nums.rend(), 0) << '\n'; // リストfruitsの最初のフルーツを表示(存在確認付き) if (!fruits.empty()) std::cout << "First fruit: " << *fruits.rbegin() << '\n'; if (empty.rbegin() == empty.rend()) std::cout << "list 'empty' is indeed empty.\n"; }
出力:
16 8 4 2 1 Sum of nums: 31 First fruit: raspberry list 'empty' is indeed empty.
関連項目
|
(C++11)
|
先頭を指す逆方向イテレータを返す
(public member function) |
|
(C++14)
|
コンテナまたは配列の終端を指す逆方向イテレータを返す
(function template) |