From 7b53f2ed582a4c6ef473691ce5415925e11316d9 Mon Sep 17 00:00:00 2001 From: Adam Emerson Date: Fri, 19 Apr 2024 08:23:17 -0400 Subject: [PATCH] include/types: Add printing of unordered_map Signed-off-by: Adam Emerson --- src/include/types.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/include/types.h b/src/include/types.h index c5754528bce..90d068606d4 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -105,6 +105,8 @@ template inline std::ostream& operator<<(std::ostream& out, const std::multiset& iset); template inline std::ostream& operator<<(std::ostream& out, const std::map& m); +template +inline std::ostream& operator<<(std::ostream& out, const std::unordered_map& m); template inline std::ostream& operator<<(std::ostream& out, const std::multimap& m); } @@ -256,6 +258,22 @@ inline std::ostream& operator<<(std::ostream& out, const std::map +inline std::ostream& +operator<<(std::ostream& out, + const std::unordered_map& m) +{ + out << "{"; + for (auto it = m.begin(); + it != m.end(); + ++it) { + if (it != m.begin()) out << ","; + out << it->first << "=" << it->second; + } + out << "}"; + return out; +} + template inline std::ostream& operator<<(std::ostream& out, const std::multimap& m) { -- 2.39.5