From 036b17fca9afcb1a136c448efb9b777042b07d77 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Fri, 18 Mar 2022 01:15:32 +0100 Subject: [PATCH 1/2] Formatting --- const_fmt/stdlib.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/const_fmt/stdlib.h b/const_fmt/stdlib.h index 684f70a..e77a3c5 100644 --- a/const_fmt/stdlib.h +++ b/const_fmt/stdlib.h @@ -187,7 +187,8 @@ concept floating_point = is_floating_point_v; template -constexpr inline void copy(const input_t* start, const input_t* end, output_t* dest_start) { +constexpr inline void copy(const input_t* start, const input_t* end, + output_t* dest_start) { auto temp = start; while (temp != end) *(dest_start++) = *(temp++); @@ -236,9 +237,9 @@ public: static_assert(sizeof...(args) == t_size, "Invalid number of arguments"); } - constexpr array() noexcept = default; + constexpr array() noexcept = default; constexpr array(const array&) = default; - constexpr array(array&&) = default; + constexpr array(array&&) = default; constexpr array& operator=(const array& other) = default; constexpr array& operator=(array&& other) = default; -- 2.45.2 From 2be63fda5a7ec85226047531e05c5f517c0e1bd9 Mon Sep 17 00:00:00 2001 From: Andreas Tsouchlos Date: Fri, 18 Mar 2022 01:23:56 +0100 Subject: [PATCH 2/2] Changed the way recursion ends in const_fmt::format_args<>() --- const_fmt/format.h | 9 +++------ const_fmt/stdlib.h | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/const_fmt/format.h b/const_fmt/format.h index ee42bb5..1f05748 100644 --- a/const_fmt/format.h +++ b/const_fmt/format.h @@ -66,16 +66,13 @@ constexpr inline void format_arg(char* dest, const char* arg) { }; -// End of recursion -template -constexpr inline void format_args(char*) { -} - template constexpr inline void format_args(char* dest, first_arg_t first_arg, args_t... args) { format_arg(dest + fmt_data_array[0].position, first_arg); - format_args(dest, args...); + + if constexpr(fmt_data_array.size() > 1) + format_args(dest, args...); } diff --git a/const_fmt/stdlib.h b/const_fmt/stdlib.h index e77a3c5..8984489 100644 --- a/const_fmt/stdlib.h +++ b/const_fmt/stdlib.h @@ -251,6 +251,9 @@ public: } } + constexpr std::size_t size() const noexcept { + return t_size; + } constexpr data_t& operator[](std::size_t index) noexcept { return m_data[index]; -- 2.45.2