std::map::iterator references non-existing object?
Considering the following code:

    class MyClass
    {
        public:
            int someInt;
            MyClass() : someInt(666) { }
    };
    
    int main()
    {
        std::map<int,MyClass> myMap;
        std::map<int,MyClass>::iterator it = myMap.end();
        const MyClass& ref = it->second;
        std::cout << ref.someInt << std::endl;
    }

Since the map is empty and `it = myMap.end()`, what Object does `it->second` reference? Is this an invalid reference because `it = myMap.end()`?

`map<int,MyClass>` does not create an instance of `MyClass`.
std::map::iterator references non-existing object?
===

Considering the following code:

    class MyClass
    {
        public:
            int someInt;
            MyClass() : someInt(666) { }
    };
    
    int main()
    {
        std::map<int,MyClass> myMap;
        std::map<int,MyClass>::iterator it = myMap.end();
        const MyClass& ref = it->second;
        std::cout << ref.someInt << std::endl;
    }

Since the map is empty and `it = myMap.end()`, what Object does `it->second` reference? Is this an invalid reference because `it = myMap.end()`?

`map<int,MyClass>` does not create an instance of `MyClass`.