diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-08-05 18:17:15 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-08-05 18:17:15 +0200 |
commit | 0f8074fdee33e830e8a7f7b3ad12971f7d9ecdf7 (patch) | |
tree | aedb5885f66c76ce6a2f20e233edea480264ffad | |
parent | 1080f632f18df9021a50ca2b58981f9fa2e4fb74 (diff) |
c++,core: Fixed compile time multiplication naming
-rw-r--r-- | c++/core/templates.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/c++/core/templates.h b/c++/core/templates.h index a3a5f7a..e704f37 100644 --- a/c++/core/templates.h +++ b/c++/core/templates.h @@ -70,7 +70,23 @@ 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"); + static_assert(i < sizeof...(Keys), "Provided index is too large for list"); +}; + +template<std::size_t i, std::size_t s, typename T, T V0, T... VN> +struct parameter_pack_value_helper { + static constexpr T value = parameter_pack_value_helper<i, s+1, T, VN...>::value; +}; + +template<std::size_t i, typename T, T V0, T... VN> +struct parameter_pack_value_helper<i, i, T, V0, VN...> { + static constexpr T value = V0; +}; + +template<std::size_t i, typename T, T... Values> +struct parameter_pack_value { + static constexpr T value = parameter_pack_value_helper<i, 0, T, Values...>::value; + static_assert(i < sizeof...(Values), "Provided index is too large for list"); }; template<typename T, T... V> @@ -83,7 +99,7 @@ struct ct_multiply<T> { template<typename T, T V0, T... VN> struct ct_multiply<T, V0, VN...> { - static constexpr T value = V0 * templ_multiply<T,VN...>::value; + static constexpr T value = V0 * ct_multiply<T,VN...>::value; }; } |