std::multimap<Key,T,Compare,Allocator>::rend, std::multimap<Key,T,Compare,Allocator>::crend
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Containers library
(C++17)
(C++11)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++23)
(C++23)
(C++20)
(C++23)
Tables
std::multimap
(C++11)
(C++11)
multimap::rendmultimap::crend
(C++11)
(C++17)
(C++23)
(C++11)
(C++11)
(C++17)
(C++20)
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)
Deduction guides (C++17)
reverse_iterator rend();
(1)
(noexcept since C++11) (constexpr since C++26)
const_reverse_iterator rend() const;
(2)
(noexcept since C++11) (constexpr since C++26)
const_reverse_iterator crend() const noexcept;
(3)
(since C++11) (constexpr since C++26)
Returns a reverse iterator past the last element of the reversed *this. It corresponds to the element preceding the first element of the non-reversed *this.
This returned iterator only acts as a sentinel. It is not guaranteed to be dereferenceable.
Contents
[edit] Return value
Reverse iterator to the element following the last element.
[edit] Complexity
Constant.
Notes
libc++ backports crend()
to C++98 mode.
[edit] Example
Run this code
#include <chrono> #include <iomanip> #include <iostream> #include <string_view> #include <map> using namespace std::chrono; int main() { const std::multimap <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'; }
Possible output:
Messages received (date order is reversed): 2023年02月17日 : 20 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日 : 24 2020年04月01日 : 42