#include #include #include #include template void update(std::map& m, F foo) { for (auto&& [key, value] : m ) value = foo(key); } int main() { std::map m { {"a", 1}, {"b", 2}, {"c", 3} }; update(m, [](std::string key) -> long long int { return std::hash{}(key); }); for (auto&& [key, value] : m) std::cout << key << ":" << value << std::endl; }