Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yukino Song
2025-02-06 09:14:18 +08:00
195 changed files with 9602 additions and 13677 deletions

View File

@@ -4,6 +4,7 @@
*/
#pragma once
// standard includes
#include <random>
#include <cstdio>
@@ -17,8 +18,7 @@ namespace uuid_util {
std::uint32_t b32[4];
std::uint64_t b64[2];
static uuid_t
generate(std::default_random_engine &engine) {
static uuid_t generate(std::default_random_engine &engine) {
std::uniform_int_distribution<std::uint8_t> dist(0, std::numeric_limits<std::uint8_t>::max());
uuid_t buf;
@@ -32,11 +32,10 @@ namespace uuid_util {
return buf;
}
static uuid_t
generate() {
static uuid_t generate() {
std::random_device r;
std::default_random_engine engine { r() };
std::default_random_engine engine {r()};
return generate(engine);
}
@@ -75,8 +74,7 @@ namespace uuid_util {
return uuid;
}
[[nodiscard]] std::string
string() const {
[[nodiscard]] std::string string() const {
std::string result;
result.reserve(sizeof(uuid_t) * 2 + 4);
@@ -103,18 +101,15 @@ namespace uuid_util {
return result;
}
constexpr bool
operator==(const uuid_t &other) const {
constexpr bool operator==(const uuid_t &other) const {
return b64[0] == other.b64[0] && b64[1] == other.b64[1];
}
constexpr bool
operator<(const uuid_t &other) const {
constexpr bool operator<(const uuid_t &other) const {
return (b64[0] < other.b64[0] || (b64[0] == other.b64[0] && b64[1] < other.b64[1]));
}
constexpr bool
operator>(const uuid_t &other) const {
constexpr bool operator>(const uuid_t &other) const {
return (b64[0] > other.b64[0] || (b64[0] == other.b64[0] && b64[1] > other.b64[1]));
}
};