From 3624d106f08b906a1a3d5e99a7e00eda212ad85b Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Mon, 20 Nov 2023 17:41:18 +0100 Subject: codec: Some initial work on schema hashes --- c++/codec/schema_hash.h | 105 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 c++/codec/schema_hash.h (limited to 'c++/codec/schema_hash.h') diff --git a/c++/codec/schema_hash.h b/c++/codec/schema_hash.h new file mode 100644 index 0000000..5690166 --- /dev/null +++ b/c++/codec/schema_hash.h @@ -0,0 +1,105 @@ +#pragma once + +#include "schema.h" + +namespace saw { +struct schema_hash_combine { + static constexpr uint64_t apply(uint64_t seed, uint64_t v){ + return (seed ^ v) * 1099511628211u; + + + return seed ^( std::hash{}(v) + 0x9e3779b9 + (seed<<6) + (seed >> 2)); + } +}; + +template +struct schema_hash { + static_assert(always_false, "Not schema_hashable"); +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 0u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 1u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 2u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 3u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 4u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 5u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 6u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 7u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 8u; +}; + +template<> +struct schema_hash> { + static constexpr uint64_t base_value = 9u; +}; + +template +struct schema_hash> { + static constexpr uint64_t base_value = 10u; +}; + +template +struct schema_hash...>> { + static constexpr uint64_t base_value = 11u; +}; + +template +struct schema_hash...>> { + static constexpr uint64_t base_value = 12u; +}; + +template +struct schema_hash> { + static constexpr uint64_t base_value = 13u; +}; + +template<> +struct schema_hash { + static constexpr uint64_t base_value = 14u; +}; + +template +struct schema_hash> { + static constexpr uint64_t base_value = 15u; +}; + +template +struct schema_hash> { + static constexpr uint64_t base_value = 16u; +}; + +} -- cgit v1.2.3