How to use range-based for() loop with std::map?
Each element of the container is a map<K, V>::value_type, which is a typedef for std::pair<const K, V>. Consequently, in C++17 or higher, you can write for (auto& [key, value]: myMap) { std::cout << key << ” has value ” << value << std::endl; } or as for (const auto& [key, value]: myMap) { std::cout << … Read more