ATLAS Offline Software
Loading...
Searching...
No Matches
std::hash< Guid > Struct Reference

#include <Guid.h>

Collaboration diagram for std::hash< Guid >:

Public Member Functions

size_t operator() (const Guid &g) const noexcept

Detailed Description

Definition at line 278 of file Guid.h.

Member Function Documentation

◆ operator()()

size_t std::hash< Guid >::operator() ( const Guid & g) const
inlinenoexcept

Definition at line 279 of file Guid.h.

279 {
280 // Treat the Guid as a 16-byte array for hashing.
281 // Checking the memory layout is contiguous and test for padding at compile time.
282 static_assert(sizeof(Guid) == (sizeof(unsigned int) + sizeof(unsigned short)
283 + sizeof(unsigned short) + sizeof(std::array<unsigned char,8>)));
284 const unsigned char* bytes = reinterpret_cast<const unsigned char*>(&g);
285 size_t hash_value = 0;
286 // Simple hash combiner: FNV-1a inspired for 128-bit data
287 constexpr size_t fnv_prime = sizeof(size_t) == 8 ? 0x100000001b3ULL : 0x01000193U;
288 constexpr size_t fnv_offset = sizeof(size_t) == 8 ? 0xcbf29ce484222325ULL : 0x811c9dc5U;
289 hash_value = fnv_offset;
290 for (size_t i = 0; i < sizeof(Guid); ++i) {
291 hash_value ^= static_cast<size_t>(bytes[i]);
292 hash_value *= fnv_prime;
293 }
294 return hash_value;
295 }
std::size_t hash_value(const SystematicSet &)
Hash function specifically for boost::hash.

The documentation for this struct was generated from the following file: