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;