make uuid_t hashable

This commit is contained in:
Fabian Posch 2024-01-09 14:38:32 -05:00
parent 7dc1ba4a6d
commit eb832213a0

View file

@ -117,6 +117,17 @@ struct is_map_key_type_same_as_enum {
}; };
// hash operator to be able use uuid_t as a hashmap key
template<>
struct std::hash<db::uuid_t> {
std::size_t operator()(const db::uuid_t& k) const {
using std::size_t;
using std::hash;
return hash<size_t>()(hash<uint64_t>()(k.uuid_upper) ^ hash<uint64_t>()(k.uuid_lower));
}
};
/** /**
* @brief Generate type conversion for enum class macros in the libpqxx library * @brief Generate type conversion for enum class macros in the libpqxx library