diff options
-rw-r--r-- | src/codec/schema.h | 8 | ||||
-rw-r--r-- | src/core/templates.h | 25 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/codec/schema.h b/src/codec/schema.h index 5021d33..df9f443 100644 --- a/src/codec/schema.h +++ b/src/codec/schema.h @@ -28,6 +28,14 @@ struct Union<Member<V, K>...> {}; template <typename T> struct Array {}; +template <class T> struct is_array { + constexpr static bool value = false; +}; + +template <class T> struct is_array<schema::Array<T>> { + constexpr static bool value = true; +}; + template<typename T, size_t S> struct FixedArray {}; template <typename... T> struct Tuple {}; diff --git a/src/core/templates.h b/src/core/templates.h index c363a16..9b4bcac 100644 --- a/src/core/templates.h +++ b/src/core/templates.h @@ -25,5 +25,30 @@ struct parameter_pack_type<N, TN, T...> { static_assert(sizeof...(T) > 0, "Exhausted parameters"); using type = typename parameter_pack_type<N - 1, T...>::type; }; +/* + * Nightmare inducing compiler problems found here. Somehow non-type + * string_literals cannot be resolved as non-type primitive template values can. + * This is the workaround + */ +template <string_literal V, string_literal Key0, string_literal... Keys> +struct parameter_key_pack_index_helper { + static constexpr size_t value = + (V == Key0) + ? (0u) + : (1u + parameter_key_pack_index_helper<V, Keys...>::value); +}; + +template <string_literal V, string_literal Key0> +struct parameter_key_pack_index_helper<V, Key0> { + static constexpr size_t value = (V == Key0) ? (0u) : (1u); +}; + +template <string_literal V, string_literal... Keys> +struct parameter_key_pack_index { + static constexpr size_t value = + parameter_key_pack_index_helper<V, Keys...>::value; + static_assert(value < sizeof...(Keys), + "Provided string_literal doesn't exist in searched list"); +}; } |