summaryrefslogtreecommitdiff
path: root/modules/codec/c++/schema_hash.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/codec/c++/schema_hash.hpp')
-rw-r--r--modules/codec/c++/schema_hash.hpp27
1 files changed, 26 insertions, 1 deletions
diff --git a/modules/codec/c++/schema_hash.hpp b/modules/codec/c++/schema_hash.hpp
index 4b537e1..d653bf4 100644
--- a/modules/codec/c++/schema_hash.hpp
+++ b/modules/codec/c++/schema_hash.hpp
@@ -15,7 +15,9 @@ struct hash_literal {
template<typename Schema>
struct schema_hash_seed {
- static_assert(always_false<Schema>, "Not schema_hashable");
+ static constexpr uint32_t apply(uint32_t seed){
+ return hash_literal<Schema::name>::apply(seed);
+ }
};
template<>
@@ -125,6 +127,29 @@ struct schema_hash_seed<schema::Tuple<T...>> {
}
};
+template<typename... T>
+struct schema_hash_seed<tmpl_group<T...>> {
+ template<uint64_t i>
+ static constexpr uint32_t apply_ele(uint32_t seed){
+ using Type = typename parameter_pack_type<i,T...>::type;
+
+ seed = schema_hash_seed<Type>::apply(seed);
+ if constexpr ( (i+1u) < sizeof...(T) ){
+ return apply_ele<i+1u>(seed);
+ }
+
+ return seed;
+ }
+
+ static constexpr uint32_t apply(uint32_t seed){
+ seed = hash_literal<tmpl_group<T...>::name>::apply(seed);
+ if constexpr (sizeof...(T)>0u){
+ seed = apply_ele<0u>(seed);
+ }
+ return seed;
+ }
+};
+
template<typename V, string_literal K>
struct schema_hash_seed<schema::Member<V,K>> {
using Schema = schema::Member<V,K>;