From d20c5ac720a0d26457c070b6d135c780af73107a Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Fri, 6 Aug 2021 00:41:55 -0400 Subject: common: uuid: Add hash function for UUID Used when UUID is a key in an unordered_map. The hash is produced by XORing the high and low 64-bits of the UUID together. --- src/common/uuid.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/common/uuid.h b/src/common/uuid.h index aeb36939a..2353179d8 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -69,3 +69,14 @@ struct UUID { static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); } // namespace Common + +namespace std { + +template <> +struct hash { + size_t operator()(const Common::UUID& uuid) const noexcept { + return uuid.uuid[1] ^ uuid.uuid[0]; + } +}; + +} // namespace std -- cgit v1.2.3