summaryrefslogtreecommitdiff
path: root/src/core/templates.h
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-06-11 20:20:52 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-06-11 20:20:52 +0200
commit85398a9410a3ab36786c1e436986309ee6163f2f (patch)
tree7eb07905cdf63c8c1080219d0537baf1a75e5a71 /src/core/templates.h
parentb84b576a221684a39ef12891bafd233ba6289b09 (diff)
c++, codec-json: Added struct to json encoding and fixed a buffer bug on
the fly
Diffstat (limited to 'src/core/templates.h')
-rw-r--r--src/core/templates.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/core/templates.h b/src/core/templates.h
index 6c0a74e..fcac61b 100644
--- a/src/core/templates.h
+++ b/src/core/templates.h
@@ -53,4 +53,21 @@ struct parameter_key_pack_index {
"Provided string_literal doesn't exist in searched list");
};
+template <size_t i, size_t s, string_literal Key0, string_literal... Keys>
+struct parameter_key_pack_type_helper {
+ static constexpr string_literal literal = parameter_key_pack_type_helper<i, s+1, Keys...>::literal;
+};
+
+template <size_t i, string_literal Key0, string_literal... Keys>
+struct parameter_key_pack_type_helper<i, i, Key0, Keys...> {
+ static constexpr string_literal literal = Key0;
+};
+
+template <size_t i, string_literal... Keys>
+struct parameter_key_pack_type {
+ static constexpr string_literal literal = parameter_key_pack_type_helper<i, 0, Keys...>::literal;
+
+ static_assert(i < sizeof...(Keys), "Provided index is too large in list");
+};
+
}