Error when pass std::map as template template argument
问题 I defined a function like this, in which there is a template template class template<typename Key, typename Value, template <typename, typename> class Map> struct ForEachOf { void operator()(const Map<Key, Value>& map, std::function<void (Key, Value)> func) { for(const auto& pair : map) { func(pair.first, pair.second); } } }; std::map<int, string> m { {1, "foo"}, {3, "bar"}}; ForEachOf<int, string, std::map> forEachOf; forEachOf(m, [](int key, string value) { cout << key << value; }); However