From 60e44cb3c8933e26d535414c49b9991cbca39154 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sat, 27 May 2023 20:19:15 +0200 Subject: c++: Added support for literal handling --- src/codec/schema.h | 8 ++++++++ src/core/templates.h | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'src') 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...> {}; template struct Array {}; +template struct is_array { + constexpr static bool value = false; +}; + +template struct is_array> { + constexpr static bool value = true; +}; + template struct FixedArray {}; template 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 { static_assert(sizeof...(T) > 0, "Exhausted parameters"); using type = typename parameter_pack_type::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 +struct parameter_key_pack_index_helper { + static constexpr size_t value = + (V == Key0) + ? (0u) + : (1u + parameter_key_pack_index_helper::value); +}; + +template +struct parameter_key_pack_index_helper { + static constexpr size_t value = (V == Key0) ? (0u) : (1u); +}; + +template +struct parameter_key_pack_index { + static constexpr size_t value = + parameter_key_pack_index_helper::value; + static_assert(value < sizeof...(Keys), + "Provided string_literal doesn't exist in searched list"); +}; } -- cgit v1.2.3