PreZero padding now being handled by preprocessing

This commit is contained in:
Andreas Tsouchlos 2022-02-13 20:47:41 +01:00
parent 4128ede5db
commit f47a23ffef
2 changed files with 8 additions and 17 deletions

View File

@ -82,17 +82,19 @@ constexpr inline void format_args(char* dest, first_arg_t first_arg,
template <auto ast> template <auto ast>
consteval inline std::array<char, get_ast_output_len<ast>()> consteval inline auto get_preproc_string() {
get_preproc_string() { std::array<char, get_ast_output_len<ast>()> result;
auto result = get_init_array<get_ast_output_len<ast>()>('f');
int i = 0; int i = 0;
for (const auto& ast_node : ast) { for (const auto& ast_node : ast) {
if (ast_node.is_char()) if (ast_node.is_char()) {
result[i++] = ast_node.get_char(); result[i++] = ast_node.get_char();
else } else {
i += ast_node.get_node().length; for (int j = 0; j < ast_node.get_node().length; ++j)
result[i++] = ast_node.get_node().has_zero_padding ? '0' : ' ';
//i += ast_node.get_node().length;
}
} }
return result; return result;

View File

@ -18,17 +18,6 @@ constexpr inline std::size_t const_pow(std::size_t base, std::size_t pow) {
} }
template <std::size_t t_n>
consteval inline std::array<char, t_n> get_init_array(char val) {
std::array<char, t_n> result;
for (auto& c : result)
c = val;
return result;
}
template <auto ast> template <auto ast>
consteval inline std::size_t count_ast_format_nodes() { consteval inline std::size_t count_ast_format_nodes() {
std::size_t result = 0; std::size_t result = 0;