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/core/templates.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/core') 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