From 18941478f8d50fc147e34faacaf09837e1d7adca Mon Sep 17 00:00:00 2001 From: Bob Chen Date: Mon, 25 Sep 2023 18:10:19 +0800 Subject: [PATCH] a --- net/socket.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/socket.h b/net/socket.h index 5f6956b0..96e19903 100644 --- a/net/socket.h +++ b/net/socket.h @@ -345,6 +345,7 @@ namespace net } namespace std { + template<> struct hash { size_t operator()(const photon::net::EndPoint& x) const { @@ -357,4 +358,18 @@ struct hash { } } }; + +template<> +struct hash { + size_t operator()(const photon::net::IPAddr& x) const { + if (x.is_ipv4()) { + hash hasher; + return hasher(x.to_nl()); + } else { + hash hasher; + return hasher(std::string_view((const char*) &x, sizeof(x))); + } + } +}; + }