]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/types: Add printing of unordered_map
authorAdam Emerson <aemerson@redhat.com>
Fri, 19 Apr 2024 12:23:17 +0000 (08:23 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Apr 2025 15:10:13 +0000 (11:10 -0400)
Signed-off-by: Adam Emerson <aemerson@redhat.com>
src/include/types.h

index c5754528bced42989d2f41461d40fd42d654ab67..90d068606d4de46563d2c1fb103a5ce62ee026d3 100644 (file)
@@ -105,6 +105,8 @@ template<class A, class Comp, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const std::multiset<A,Comp,Alloc>& iset);
 template<class A, class B, class Comp, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const std::map<A,B,Comp,Alloc>& m);
+template<class A, class B, class Hash, class KeyEqual>
+inline std::ostream& operator<<(std::ostream& out, const std::unordered_map<A,B,Hash, KeyEqual>& m);
 template<class A, class B, class Comp, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const std::multimap<A,B,Comp,Alloc>& m);
 }
@@ -256,6 +258,22 @@ inline std::ostream& operator<<(std::ostream& out, const std::map<A,B,Comp,Alloc
   return out;
 }
 
+template <class A, class B, class Hash, class KeyEqual>
+inline std::ostream&
+operator<<(std::ostream& out,
+          const std::unordered_map<A, B, Hash, KeyEqual>& 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<class A, class B, class Comp, class Alloc>
 inline std::ostream& operator<<(std::ostream& out, const std::multimap<A,B,Comp,Alloc>& m)
 {