#include <map>
#include <unordered_map>
#include <vector>
#include <iostream>
template <template <typename...> typename Map, typename Key, typename Value>
std::vector<Key> keys(const Map<Key, Value>& map)
{
std::vector<Key> keys;
keys.reserve(keys.size());
for (const auto& [key, value] : map)
keys.push_back(key);
return keys;
}
int main()
{
std::unordered_map<int, std::string> stringMap;
stringMap[3] = "hello";
stringMap[2] = "bye";
auto stringKeys = keys(stringMap);
for (const auto& key : stringKeys)
std::cout << key << std::endl;
std::cout << std::endl;
std::map<std::string, double> doubleMap;
doubleMap["wow"] = 1.2f;
doubleMap["great"] = 4.5f;
auto doubleKeys = keys(doubleMap);
for (const auto& key : doubleKeys)
std::cout << key << std::endl;
std::cout << std::endl;
return 0;
}