Does std::unordered_map operator[] do zero-initialization for non-exisiting key?

On the site you linked it says:

When the default allocator is used, this results in the key being copy
constructed from key and the mapped value being value-initialized.

So the int is value-initialized:

The effects of value initialization are:

[…]

4) otherwise, the object is zero-initialized

This is why the result is 0.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)