summaryrefslogtreecommitdiff
path: root/c++/core/templates.h
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2023-11-27 23:03:57 +0100
committerClaudius "keldu" Holeksa <mail@keldu.de>2023-11-27 23:03:57 +0100
commitaa2ecacd2e477eb5748f060d33138e0c12c0634f (patch)
treed0360b420ecddaf6b9986c004ea3e0b962c9ca1b /c++/core/templates.h
parent0cf04f2d1ba5ed2a18fe9f3501f363cb3ff76c9f (diff)
codec,core,tools: Adding dangling experimental changes
Diffstat (limited to 'c++/core/templates.h')
-rw-r--r--c++/core/templates.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/c++/core/templates.h b/c++/core/templates.h
index e2851a0..2eb0f7e 100644
--- a/c++/core/templates.h
+++ b/c++/core/templates.h
@@ -105,6 +105,8 @@ struct ct_multiply<T, V0, VN...> {
namespace impl {
template<typename T, size_t i>
struct ct_convert_digits_table_helper {
+ static_assert(i <= 15, "Only conversion up to hex is supported");
+
static constexpr std::array<T, 16> table = {
'0', '1', '2', '3',
'4', '5', '6', '7',
@@ -119,18 +121,21 @@ template<uint64_t Num, uint64_t Base, uint64_t... Digs>
struct ct_convert_digits_helper {
static constexpr size_t size = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::size;
static constexpr std::array<uint64_t, size> value = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::value;
+ static constexpr string_literal literal = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::literal;
};
template<uint64_t Base, uint64_t... Digs>
struct ct_convert_digits_helper<0, Base, Digs...> {
static constexpr size_t size = sizeof...(Digs);
static constexpr std::array<uint64_t, size> value = {Digs...};
+ static constexpr string_literal literal = {{ct_convert_digits_table_helper<char, Digs>::value..., '\0'}};
};
template<uint64_t Base>
struct ct_convert_digits_helper<0, Base> {
static constexpr size_t size = 0;
static constexpr std::array<uint64_t, 1> value = {0};
+ static constexpr string_literal literal = "0"_sl;
};
}
@@ -140,5 +145,6 @@ struct ct_convert_to_digits {
static constexpr size_t size = impl::ct_convert_digits_helper<Num, Base>::size;
static constexpr std::array<uint64_t, size> value = impl::ct_convert_digits_helper<Num, Base>::value;
+ static constexpr string_literal literal = impl::ct_convert_digits_helper<Num,Base>::literal;
};
}