cmu-db / 15445-bootcamp

A basic introduction to coding in modern C++.
Apache License 2.0
721 stars 142 forks source link

fix unintended copying #11

Closed qycyfjy closed 11 months ago

qycyfjy commented 12 months ago

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.

https://godbolt.org/z/GsM6eYWMa

qycyfjy commented 11 months ago

resolved You can check again to see if there are any other problems or merge it directly.

qycyfjy commented 11 months ago

oops, Looks like I messed up the commit