From: Adam Emerson Date: Fri, 19 Apr 2024 12:23:17 +0000 (-0400) Subject: include/types: Add printing of unordered_map X-Git-Tag: testing/wip-vshankar-testing-20250407.170244-debug~16^2~46 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=7b53f2ed582a4c6ef473691ce5415925e11316d9;p=ceph-ci.git include/types: Add printing of unordered_map Signed-off-by: Adam Emerson --- 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) {