Nexus Engine  v0.0.1
Loading...
Searching...
No Matches
NetworkAddress.inl
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2
3#pragma once
4
5template <>
6struct NEXUS_API std::hash<Nexus::Network::NetworkAddress> {
7 Nexus::usize operator()(const Nexus::Network::NetworkAddress& address) const noexcept {
8 const Nexus::usize h1 = std::hash<std::string>{}(address.Host());
9 const Nexus::usize h2 = std::hash<Nexus::uint16>{}(address.Port());
10
11 // 64-bit mix inspired by the standard hash-combine pattern.
12 static constexpr auto PHI = 0x9e3779b97f4a7c15ULL;
13 return h1 ^ (h2 + static_cast<Nexus::usize>(PHI) + (h1 << 6) + (h1 >> 2));
14 }
15};
#define NEXUS_API
Definition Export.hpp:12
Definition NetworkAddress.cppm:14
std::size_t usize
Definition Types.cppm:25
Nexus::usize operator()(const Nexus::Network::NetworkAddress &address) const noexcept
Definition NetworkAddress.inl:7