diff options
| author | 2021-08-06 00:41:55 -0400 | |
|---|---|---|
| committer | 2021-08-06 00:41:55 -0400 | |
| commit | d20c5ac720a0d26457c070b6d135c780af73107a (patch) | |
| tree | 163d9f08b60a8d160a125d50012328fd97bc4bbb | |
| parent | Merge pull request #6813 from Morph1984/hex-string-to-uuid (diff) | |
| download | yuzu-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.h | 11 |
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 { | |||
| 69 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); | 69 | static_assert(sizeof(UUID) == 16, "UUID is an invalid size!"); |
| 70 | 70 | ||
| 71 | } // namespace Common | 71 | } // namespace Common |
| 72 | |||
| 73 | namespace std { | ||
| 74 | |||
| 75 | template <> | ||
| 76 | struct 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 | ||