I was doing a simple map program but ended up with this question. The c++ doc says this:
Access element If k matches the key of an element in the container, the func
The statement of "using its default constructor" is confusing. More precisely, for std::map::operator[], if the key does not exist, the inserted value will be value-initialized.
When the default allocator is used, this results in the key being copy constructed from key and the mapped value being value-initialized.
For int
, it means zero-initialization.
4) otherwise, the object is zero-initialized.