std::multimap<Key,T,Compare,Allocator>::end, std::multimap<Key,T,Compare,Allocator>::cend

Returns an iterator to the element following the last element of the multimap.

# Declarations

iterator end();

(noexcept since C++11)

const_iterator end() const;

(noexcept since C++11)

const_iterator cend() const noexcept;

(since C++11)

# Return value

Iterator to the element following the last element.

# Notes

libc++ backports cend() to C++98 mode.

# Example

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iostream>
#include <map>
#include <string>
 
int main()
{
    auto show_node = [](const auto& node, char ending = '\n')
    {
        std::cout << "{ " << node.first << ", " << node.second << " }" << ending;
    };
 
    std::multimap<std::size_t, std::string> mmap;
    assert(mmap.begin() == mmap.end());   // OK
    assert(mmap.cbegin() == mmap.cend()); // OK
 
    mmap.insert({ sizeof(long), "LONG" });
    show_node(*(mmap.cbegin()));
    assert(mmap.begin() != mmap.end());   // OK
    assert(mmap.cbegin() != mmap.cend()); // OK
    mmap.begin()->second = "long";
    show_node(*(mmap.cbegin()));
 
    mmap.insert({ sizeof(int), "int" });
    show_node(*mmap.cbegin());
 
    mmap.insert({ sizeof(short), "short" });
    show_node(*mmap.cbegin());
 
    mmap.insert({ sizeof(char), "char" });
    show_node(*mmap.cbegin());
 
    mmap.insert({{ sizeof(float), "float" }, { sizeof(double), "double"}});
 
    std::cout << "mmap = { ";
    std::for_each(mmap.cbegin(), mmap.cend(), [&](const auto& n) { show_node(n, ' '); });
    std::cout << "};\n";
}

# See also