Questions tagged «zero-initialization»

2
std :: unordered_map运算符[]是否对不存在的密钥进行零初始化?
根据cppreference.com,std::map::operator[]对于不存在的值进行零初始化。 但是,同一站点没有提及的零初始化std::unordered_map::operator[],但确实有一个依赖于此的示例。 当然,这只是参考站点,而不是标准站点。那么,下面的代码是否正确? #include <unordered_map> int main() { std::unordered_map<int, int> map; return map[42]; // is this guaranteed to return 0? }
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.