I already have this working code:
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream &out, std::map<T1, T2> &map){
for (auto it = map.begin(); it != map.end(); ++it) {
out << it-> first << ", " << it->second << '\n';
}
return out;
}
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream &out, std::unordered_map<T1, T2> &map){
for (auto it = map.begin(); it != map.end(); ++it) {
out << it-> first << ", " << it->second << '\n';
}
return out;
}
As you can see both functions are almost identical. Is there a way to remove one and use only one abstract function?