From 58be07a8b0107f0b06531f2928d6fcd1377fa1ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 29 Nov 2022 21:36:56 -0500
Subject: [PATCH] infohash: add to_view()

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

diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h
index 3811ea22..7ec7292d 100644
--- a/include/opendht/infohash.h
+++ b/include/opendht/infohash.h
@@ -249,6 +249,8 @@ public:
     template <size_t M>
     OPENDHT_PUBLIC friend std::istream& operator>> (std::istream& s, Hash<M>& h);
 
+    /** Returns view to thread-allocated memory, only valid until the next call to this function. */
+    std::string_view to_view() const { return std::string_view(to_c_str(), N*2); }
     const char* to_c_str() const;
 
     std::string toString() const;
-- 
GitLab