diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-11 20:20:52 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-06-11 20:20:52 +0200 |
commit | 85398a9410a3ab36786c1e436986309ee6163f2f (patch) | |
tree | 7eb07905cdf63c8c1080219d0537baf1a75e5a71 /src/core | |
parent | b84b576a221684a39ef12891bafd233ba6289b09 (diff) |
c++, codec-json: Added struct to json encoding and fixed a buffer bug on
the fly
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/error.cpp | 2 | ||||
-rw-r--r-- | src/core/templates.h | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/src/core/error.cpp b/src/core/error.cpp index 9520972..e777c84 100644 --- a/src/core/error.cpp +++ b/src/core/error.cpp @@ -32,7 +32,7 @@ const std::string_view error::get_message() const { } bool error::failed() const { - return this->is_type<err::no_error>(); + return !this->is_type<err::no_error>(); } bool error::is_critical() const { 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"); +}; + } |