template <typename Key, typename Value>
std::vector<Key> keys(const std::map<Key, Value> &m) { ... }
I'd like to write an overload that works also with the indices interface of multi_index_container.
template <typename Key, typename Value>
std::vector<Key> keys(const std::map<Key, Value> &m) { ... }
I suspect that you only need to make your template a little more generic, something like (untested):
template <typename C>
std::vector<typename C::key_type> keys(const C& c) {
std::vector<typename C::key_type> result;
result.reserve(c.size());
for (const auto& entry : c) {
result.emplace_back(entry.first);
}
return result;
}