Код: Выделить всё
union uuid_t {
unsigned char e[16];
};
template
constexpr uuid_t operator ""_uuid() {
constexpr auto N = sizeof...(Cs);
static_assert(N == 36,
"UUID literal must be exactly 36 chars (8-4-4-4-12)");
// build a null-terminated buffer
constexpr char str[N + 1] = { Cs..., '\0' };
// dash checks
static_assert(str[8] == '-' &&
str[13] == '-' &&
str[18] == '-' &&
str[23] == '-',
"Dashes must be at 8,13,18,23");
// constexpr lambda to convert one hex char -> 0..15
constexpr auto hex_val = [](const char c) {
return static_cast(
(c >= '0' && c = 'a' && c = 'A' && c
Подробнее здесь: [url]https://stackoverflow.com/questions/79657502/gcc-clang-unresolved-user-defined-literal-template-operator[/url]
Мобильная версия