changes in tmp dir
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
(print
|
|
||||||
"ahoj"
|
|
||||||
; this comment is problem
|
|
||||||
)
|
|
||||||
(print "lisp")
|
|
||||||
34
tmp/uuid.cpp
Normal file
34
tmp/uuid.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
// https://mariusbancila.ro/blog/2018/02/27/stduuid-a-cpp-library-for-universally-unique-identifiers/
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <random>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
std::string get_uuid() {
|
||||||
|
static std::random_device dev;
|
||||||
|
static std::mt19937_64 rng(dev());
|
||||||
|
|
||||||
|
std::uniform_int_distribution<int> dist(0, 15);
|
||||||
|
const char *v = "0123456789abcdef";
|
||||||
|
const bool dash[] = { 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
std::string res;
|
||||||
|
res.reserve(40);
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
if (dash[i]) res += "-";
|
||||||
|
res += v[dist(rng)];
|
||||||
|
res += v[dist(rng)];
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
// g++ uuid_test.cpp
|
||||||
|
int main() {
|
||||||
|
auto uuid_str = get_uuid();
|
||||||
|
|
||||||
|
std::cout << uuid_str << std::endl;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user