summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Morph2021-08-06 00:41:55 -0400
committerGravatar Morph2021-08-06 00:41:55 -0400
commitd20c5ac720a0d26457c070b6d135c780af73107a (patch)
tree163d9f08b60a8d160a125d50012328fd97bc4bbb
parentMerge pull request #6813 from Morph1984/hex-string-to-uuid (diff)
downloadyuzu-d20c5ac720a0d26457c070b6d135c780af73107a.tar.gz
yuzu-d20c5ac720a0d26457c070b6d135c780af73107a.tar.xz
yuzu-d20c5ac720a0d26457c070b6d135c780af73107a.zip
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.
-rw-r--r--src/common/uuid.h11
1 files changed, 11 insertions, 0 deletions
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 {
69static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); 69static_assert(sizeof(UUID) == 16, "UUID is an invalid size!");
70 70
71} // namespace Common 71} // namespace Common
72
73namespace std {
74
75template <>
76struct hash<Common::UUID> {
77 size_t operator()(const Common::UUID& uuid) const noexcept {
78 return uuid.uuid[1] ^ uuid.uuid[0];
79 }
80};
81
82} // namespace std