18 std::mt19937_64 engine {std::random_device()()};
19 std::uniform_int_distribution<std::uint64_t> dist {0, 255};
21 for (
auto index = 0; index < 16; ++index)
23 m_uuid[index] =
static_cast<unsigned char>(dist(engine));
29 std::stringstream hex;
30 hex << std::hex << std::setfill(
'0');
32 for (
int i = 0; i < 16; ++i)
34 hex << std::setw(2) << static_cast<int>(
m_uuid[i]);
36 if (i == 3 || i == 5 || i == 7 || i == 9)
47 this->m_uuid = std::move(g.m_uuid);
48 this->m_str = std::move(g.m_str);
55 this->m_uuid = std::move(g.m_uuid);
56 this->m_str = std::move(g.m_str);
64 this->m_uuid = g.m_uuid;
65 this->m_str = g.m_str;
72 this->m_uuid = g.m_uuid;
73 this->m_str = g.m_str;
88 h ^=
static_cast<std::size_t
>(b) + 0x9e3779b9 + (h << 6) + (h >> 2);
100 return m_uuid == rhs.m_uuid;
105 return !operator==(rhs);
Contains a 128bit randomly generated UUID, along with helper functions.
std::array< unsigned char, 16 > m_uuid
UUID.
bool operator==(const UUID &rhs) noexcept
Equality comparison.
const std::string & str() const noexcept
Get the UUID as a string.
bool operator!=(const UUID &rhs) noexcept
Inequality comparison.
std::string m_str
String representation.
UUID & operator=(UUID &&) noexcept
Move assignment operator.
~UUID() noexcept
Destructor.
std::size_t hash() noexcept
Get the UUID as a hash.