std::map<Key,T,Compare,Allocator>:: rend, std::map<Key,T,Compare,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::map
| 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 <chrono> #include <iomanip> #include <iostream> #include <string_view> #include <map> using namespace std::chrono; int main() { const std::map<year_month_day, int> messages { {February/17/2023, 10}, {February/17/2023, 20}, {February/16/2022, 30}, {October/22/2022, 40}, {June/14/2022, 50}, {November/23/2021, 60}, {December/10/2022, 55}, {December/12/2021, 45}, {April/1/2020, 42}, {April/1/2020, 24} }; std::cout << "Messages received (date order is reversed):\n"; for (auto it = messages.crbegin(); it != messages.crend(); ++it) std::cout << it->first << " : " << it->second << '\n'; }
出力例:
Messages received (date order is reversed): 2023-02-17 : 10 2022-12-10 : 55 2022-10-22 : 40 2022-06-14 : 50 2022-02-16 : 30 2021-12-12 : 45 2021-11-23 : 60 2020-04-01 : 42
関連項目
|
(C++11)
|
先頭を指す逆方向イテレータを返す
(public member function) |
|
(C++14)
|
コンテナまたは配列の終端を指す逆方向イテレータを返す
(function template) |