fixed indentation for uuid class
This commit is contained in:
parent
920fdc68ed
commit
40dfc30dae
|
|
@ -6,7 +6,6 @@
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace matador::utils {
|
namespace matador::utils {
|
||||||
|
|
||||||
class uuid {
|
class uuid {
|
||||||
public:
|
public:
|
||||||
using uuid_array = std::array<uint32_t, 4>;
|
using uuid_array = std::array<uint32_t, 4>;
|
||||||
|
|
@ -39,13 +38,7 @@ private:
|
||||||
// Hash specialization to allow use in unordered containers
|
// Hash specialization to allow use in unordered containers
|
||||||
template<>
|
template<>
|
||||||
struct std::hash<matador::utils::uuid> {
|
struct std::hash<matador::utils::uuid> {
|
||||||
std::size_t operator()(const matador::utils::uuid& u) const noexcept {
|
std::size_t operator()(const matador::utils::uuid &u) const noexcept;
|
||||||
std::size_t h = 0;
|
|
||||||
for (const uint32_t val : u.data()) {
|
|
||||||
h ^= std::hash<uint32_t>{}(val) + 0x9e3779b9 + (h << 6) + (h >> 2);
|
|
||||||
}
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //MATADOR_UUID_HPP
|
#endif //MATADOR_UUID_HPP
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
namespace matador::utils {
|
namespace matador::utils {
|
||||||
|
|
||||||
uuid uuid::generate() {
|
uuid uuid::generate() {
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937_64 gen(rd());
|
std::mt19937_64 gen(rd());
|
||||||
|
|
@ -73,3 +72,11 @@ bool operator<( const uuid& lhs, const uuid& rhs ) {
|
||||||
return lhs._data < rhs._data;
|
return lhs._data < rhs._data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t std::hash<matador::utils::uuid>::operator()(const matador::utils::uuid &u) const noexcept {
|
||||||
|
std::size_t h = 0;
|
||||||
|
for (const uint32_t val: u.data()) {
|
||||||
|
h ^= std::hash<uint32_t>{}(val) + 0x9e3779b9 + (h << 6) + (h >> 2);
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue