Namespaces
Variants

std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: end, std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>:: cend

From cppreference.net

iterator end ( ) noexcept ;
(1) (C++23以降)
(C++26以降 constexpr)
const_iterator end ( ) const noexcept ;
(2) (C++23以降)
(C++26以降 constexpr)
const_iterator cend ( ) const noexcept ;
(3) (C++23以降)
(C++26以降 constexpr)

* this の最後の要素の次を指すイテレータを返します。

この返されたイテレータはセンチネルとしてのみ機能します。これが デリファレンス可能 であることは保証されません。

range-begin-end.svg

目次

戻り値

最後の要素の次のイテレータ。

計算量

定数。

#include <iostream>
#include <flat_map>
int main()
{
    std::flat_map<int, double> map{{4, 4.13}, {9, 9.24}, {1, 1.09}};
    for (auto it = map.cbegin(); it != map.cend(); ++it)
        std::cout << '[' << it->first << "] = " << it->second << '\n';
    // std::mapの双方向イテレータとは異なり、std::flat_mapのイテレータは
    // ランダムアクセス可能なので、operator[]で使用できます:
    auto it = map.cbegin();
    assert(it[0] == map[1]);
    assert(it[1] == map[4]);
    assert(it[2] == map[9]);
}

出力:

[1] = 1.09
[4] = 4.13
[9] = 9.24

関連項目

先頭を指すイテレータを返す
(public member function)
(C++11) (C++14)
コンテナまたは配列の終端を指すイテレータを返す
(function template)