utils::to_string: Add printers for pairs+maps
This commit is contained in:
18
to_string.hh
18
to_string.hh
@@ -80,6 +80,12 @@ to_string(std::initializer_list<Printable> items) {
|
||||
return "[" + join(", ", std::begin(items), std::end(items)) + "]";
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
std::ostream& operator<<(std::ostream& os, const std::pair<K, V>& p) {
|
||||
os << "{" << p.first << ", " << p.second << "}";
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& os, const std::unordered_set<T>& items) {
|
||||
os << "{" << join(", ", items) << "}";
|
||||
@@ -98,6 +104,18 @@ std::ostream& operator<<(std::ostream& os, const std::array<T, N>& items) {
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename K, typename V, typename... Args>
|
||||
std::ostream& operator<<(std::ostream& os, const std::unordered_map<K, V, Args...>& items) {
|
||||
os << "{" << join(", ", items) << "}";
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename K, typename V, typename... Args>
|
||||
std::ostream& operator<<(std::ostream& os, const std::map<K, V, Args...>& items) {
|
||||
os << "{" << join(", ", items) << "}";
|
||||
return os;
|
||||
}
|
||||
|
||||
namespace experimental {
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user