Consider the code:
#include <unordered_map>
#include <array>
#include <iostream>
int main () {
std::unordered_map<int, std::array<int, 5>> map;
map[42][0] = 1;
for (int i = 0; i < 5; i++) {
std::cout << map[42][i] << " ";
}
}
This prints 1 0 0 0 0
on my system. The content of std::array
held inside std::map
was value-initialized upon insertion (i.e. all integers inside array were set to 0). Does the standard guarantee this? I should never expect the array used as value of the map to contain garbage?