summaryrefslogtreecommitdiff
path: root/src/core/templates.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/templates.h')
-rw-r--r--src/core/templates.h25
1 files changed, 25 insertions, 0 deletions
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");
+};
}