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

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

# 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 <iostream>
#include <map>
 
int main()
{
    std::map<int, float> num_map;
    num_map[4] = 4.13;
    num_map[9] = 9.24;
    num_map[1] = 1.09;
    // Calls num_map.begin() and num_map.end()
    for (auto it = num_map.begin(); it != num_map.end(); ++it)
        std::cout << it->first << ", " << it->second << '\n';
}

# See also