Is a pointer inserted into a map due to a missing index always NULL?
std::map<int, Foo*> myMap;
Foo* myFoo = myMap[0];
Is myFoo guaranteed to be NULL?
From cppreference:
If an insertion is performed, the mapped value is value-initialized (default-constructed for class types, zero-initialized otherwise) and a reference to it is returned
So yes, this is guaranteed to be NULL
.
Yes, when a missing index is accessed, it is value-initialized, implying a null pointer is returned in this case (as it is a scalar value).
Source : http://en.cppreference.com/w/cpp/container/map/operator_at