Question

When I access an element in std::unordered_map using operator [] for the first time, it is automatically created. What (if any) are guarantees about its initialization? (It is guaranteed to be value initialized, or only to be constructed)?

Example:

std::unordered_map<void *, size_t> size;
char *test = new char[10];
size[test] += 10;

Is size[test] guaranteed to be 10 at the end of this sequence?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top