From ba94f43b016f9c07bd806e445ae23aab82510d7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Thu, 18 May 2023 00:44:47 -0400
Subject: [PATCH] hash: add fmt formatter

---
 include/opendht/infohash.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h
index 25753614..7de93365 100644
--- a/include/opendht/infohash.h
+++ b/include/opendht/infohash.h
@@ -22,6 +22,7 @@
 #include "rng.h"
 
 #include <msgpack.hpp>
+#include <fmt/core.h>
 
 #ifndef _WIN32
 #include <netinet/in.h>
@@ -394,3 +395,10 @@ Hash<N>::toString() const
 }
 
 }
+
+template <size_t N>
+struct fmt::formatter<dht::Hash<N>>: formatter<string_view> {
+  constexpr auto format(const dht::Hash<N>& c, format_context& ctx) const {
+    return formatter<string_view>::format(c.to_view(), ctx);
+  }
+};
-- 
GitLab