From 9344c470eed4f71cf2969fbd563e47331b8b04a5 Mon Sep 17 00:00:00 2001 From: matrackif Date: Thu, 9 Dec 2021 11:14:05 +0100 Subject: [PATCH] Integrate suggested changes * Remove static from detail functions, they are no longer member functions of a class and static is unnecessary. * Change comment from "amount" to "number" --- include/fmt/chrono.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index e4db4735..585eb6b6 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1389,20 +1389,20 @@ inline std::chrono::duration get_milliseconds( #endif } -// Returns the amount of digits according to the c++ 20 spec +// Returns the number of digits according to the c++ 20 spec // In the range [0, 18], if more than 18 fractional digits are required, // then we return 6 for microseconds precision. -static constexpr int num_digits(long long num, long long den, int n = 0) { +constexpr int num_digits(long long num, long long den, int n = 0) { return num % den == 0 ? n : (n > 18 ? 6 : num_digits(num * 10, den, n + 1)); } -static constexpr long long pow10(std::uint32_t n) { +constexpr long long pow10(std::uint32_t n) { return n == 0 ? 1 : 10 * pow10(n - 1); } template ::is_signed)> -static constexpr std::chrono::duration abs( +constexpr std::chrono::duration abs( std::chrono::duration d) { // We need to compare the duration using the count() method directly // due to a compiler bug in clang-11 regarding the spaceship operator, @@ -1581,7 +1581,7 @@ struct chrono_formatter { } template void write_fractional_seconds(Duration d) { - static constexpr auto fractional_width = + constexpr auto fractional_width = detail::num_digits(Duration::period::num, Duration::period::den); using subsecond_precision = std::chrono::duration<