std::unordered_map::emplace object creation
问题 I was in the process of selecting one of two methods of putting things into an unordered_map: std::unordered_map<Key, Value> map; map.emplace( std::piecewise_construct, std::forward_as_tuple(a), std::forward_as_tuple(b, c, d)); vs std::unordered_map<Key, DifferentValue> map; auto& value = map[a]; if (value.isDefaultInitialized()) value = DifferentValue(b, c, d); I did some experiments to see which one would perform better to find that when inserting unique elements, the behaviour (as in