From f47a23ffef0b9461251ed8c3ef9964f8fb993969 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Sun, 13 Feb 2022 20:47:41 +0100 Subject: [PATCH] PreZero padding now being handled by preprocessing --- const_fmt/format.h | 14 ++++++++------ const_fmt/utility.h | 11 ----------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/const_fmt/format.h b/const_fmt/format.h index c6242ea..9d42efd 100644 --- a/const_fmt/format.h +++ b/const_fmt/format.h @@ -82,17 +82,19 @@ constexpr inline void format_args(char* dest, first_arg_t first_arg, template -consteval inline std::array()> -get_preproc_string() { - auto result = get_init_array()>('f'); +consteval inline auto get_preproc_string() { + std::array()> result; int i = 0; for (const auto& ast_node : ast) { - if (ast_node.is_char()) + if (ast_node.is_char()) { result[i++] = ast_node.get_char(); - else - i += ast_node.get_node().length; + } else { + 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; diff --git a/const_fmt/utility.h b/const_fmt/utility.h index dd11140..e87a664 100644 --- a/const_fmt/utility.h +++ b/const_fmt/utility.h @@ -18,17 +18,6 @@ constexpr inline std::size_t const_pow(std::size_t base, std::size_t pow) { } -template -consteval inline std::array get_init_array(char val) { - std::array result; - - for (auto& c : result) - c = val; - - return result; -} - - template consteval inline std::size_t count_ast_format_nodes() { std::size_t result = 0;