Just did a bit of naughty type punning:
namespace std
{
template <> struct hash<neolib::uuid>
{
typedef neolib::uuid argument_type;
typedef std::size_t result_type;
result_type operator()(argument_type const& aUuid) const
{
if constexpr (sizeof(std::size_t) == sizeof(uint64_t))
{
// type punning is serious business...
struct badf00d
{
uint64_t bat;
uint64_t pangolin;
};
badf00d covid19;
std::memcpy(&covid19, &aUuid, sizeof(covid19));
return covid19.bat ^ covid19.pangolin;
}
else
{
// type punning is serious business...
struct badf00d
{
uint32_t bat1;
uint32_t bat2;
uint32_t pangolin1;
uint32_t pangolin2;
};
badf00d covid19;
std::memcpy(&covid19, &aUuid, sizeof(covid19));
return covid19.bat1 ^ covid19.bat2 ^ covid19.pangolin1 ^ covid19.pangolin2;
}
}
};
}
https://github.com/i42output/neolib/blob/master/include/neolib/uuid.hpp#L123
/Flibble
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
“You won’t burn in hell. But be nice anyway.” – Ricky Gervais
“I see Atheists are fighting and killing each other again, over who doesn’t believe in any God the most. Oh, no..wait.. that never happens.” – Ricky Gervais
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."