summaryrefslogtreecommitdiff
path: root/c++/core/templates.h
diff options
context:
space:
mode:
Diffstat (limited to 'c++/core/templates.h')
-rw-r--r--c++/core/templates.h20
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;
};
}