Suppose I have a map
std::map<int, double> foo;
Is the behaviour on my writing foo[2] += 3.0;
defined? That is, are any implicitly added map elements automatically initialised (hopefully to 0.0
) in my case?
If not, am I introducing a truck-load of undefined behaviour? If so, could I do something funky with an allocator to enforce initialisation to 0.0
?