Namespaces
Variants

std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: rend, std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: crend

From cppreference.net

reverse_iterator rend ( ) noexcept ;
(1) (自 C++23 起)
(自 C++26 起为 constexpr)
const_reverse_iterator rend ( ) const noexcept ;
(2) (自 C++23 起)
(自 C++26 起为 constexpr)
const_reverse_iterator crend ( ) const noexcept ;
(3) (自 C++23 起)
(自 C++26 起为 constexpr)

返回一个反向迭代器,指向反转后 * this 的最后一个元素之后的位置。它对应于非反转 * this 的第一个元素之前的位置。

此返回的迭代器仅作为哨兵使用。不保证其具有 可解引用性

range-rbegin-rend.svg

目录

返回值

指向最后一个元素之后元素的反向迭代器。

复杂度

常量。

示例

#include <chrono>
#include <iomanip>
#include <iostream>
#include <string_view>
#include <flat_map>
using namespace std::chrono;
int main()
{
    const std::flat_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';
}

可能的输出:

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

另请参阅

返回指向起始的反向迭代器
(公开成员函数)
(C++14)
返回容器或数组的逆向末端迭代器
(函数模板)