Namespaces
Variants

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

From cppreference.net

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

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

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

range-begin-end.svg

目次

戻り値

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

計算量

定数。

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

出力:

[1] = 19
[4] = 13
[4] = 42
[9] = 94

関連項目

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