From 06372b772f1687619820de00761f008b1f6209ce Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Sun, 31 Mar 2024 16:42:51 -0500 Subject: [PATCH] Fix another warning --- src/utils/microfmt.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/microfmt.hpp b/src/utils/microfmt.hpp index cec2ab9..ba47db7 100644 --- a/src/utils/microfmt.hpp +++ b/src/utils/microfmt.hpp @@ -47,6 +47,10 @@ namespace microfmt { } #endif + template U to(V v) { + return static_cast(v); // A way to cast to U without "warning: useless cast to type" + } + enum class alignment { left, right }; struct format_options { @@ -84,7 +88,7 @@ namespace microfmt { // log_2(x) == 63 - clz(x) // 1 + (63 - clz(value)) / (63 - clz(1 << shift)) // 63 - clz(1 << shift) is the same as shift - auto n_digits = static_cast(1 + (63 - clz(value)) / shift); + auto n_digits = to(1 + (63 - clz(value)) / shift); std::string number; number.resize(n_digits); std::size_t i = n_digits - 1;