Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
beef9999 committed Sep 25, 2023
1 parent c782e0b commit 1894147
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ namespace net
}

namespace std {

template<>
struct hash<photon::net::EndPoint> {
size_t operator()(const photon::net::EndPoint& x) const {
Expand All @@ -357,4 +358,18 @@ struct hash<photon::net::EndPoint> {
}
}
};

template<>
struct hash<photon::net::IPAddr> {
size_t operator()(const photon::net::IPAddr& x) const {
if (x.is_ipv4()) {
hash<uint32_t> hasher;
return hasher(x.to_nl());
} else {
hash<std::string_view> hasher;
return hasher(std::string_view((const char*) &x, sizeof(x)));
}
}
};

}

0 comments on commit 1894147

Please sign in to comment.