20 generate(std::default_random_engine &engine) {
21 std::uniform_int_distribution<std::uint8_t> dist(0, std::numeric_limits<std::uint8_t>::max());
24 for (
auto &el : buf.b8) {
28 buf.b8[7] &= (std::uint8_t) 0b00101111;
29 buf.b8[9] &= (std::uint8_t) 0b10011111;
38 std::default_random_engine engine { r() };
40 return generate(engine);
43 [[nodiscard]] std::string
47 result.reserve(
sizeof(
uuid_t) * 2 + 4);
49 auto hex = util::hex(*
this,
true);
50 auto hex_view = hex.to_string_view();
52 std::string_view slices[] = {
53 hex_view.substr(0, 8),
54 hex_view.substr(8, 4),
55 hex_view.substr(12, 4),
56 hex_view.substr(16, 4)
58 auto last_slice = hex_view.substr(20, 12);
60 for (
auto &slice : slices) {
61 std::copy(std::begin(slice), std::end(slice), std::back_inserter(result));
63 result.push_back(
'-');
66 std::copy(std::begin(last_slice), std::end(last_slice), std::back_inserter(result));
72 operator==(
const uuid_t &other)
const {
73 return b64[0] == other.b64[0] && b64[1] == other.b64[1];
77 operator<(
const uuid_t &other)
const {
78 return (b64[0] < other.b64[0] || (b64[0] == other.b64[0] && b64[1] < other.b64[1]));
82 operator>(
const uuid_t &other)
const {
83 return (b64[0] > other.b64[0] || (b64[0] == other.b64[0] && b64[1] > other.b64[1]));