When using range-based for loop on unordered_map, the named variable should have a type like std::pair<const Key, Value>. If we ignore the const, this will cause some unnecessary copying.
Maybe we can show the usage of auto and structured binding here.
When using
range-based for loop
onunordered_map
, the named variable should have a type likestd::pair<const Key, Value>
. If we ignore theconst
, this will cause some unnecessary copying.Maybe we can show the usage of
auto
andstructured binding
here.https://godbolt.org/z/GsM6eYWMa