Fix another warning

This commit is contained in:
Jeremy 2024-03-31 16:42:51 -05:00
parent 40696e8d02
commit 06372b772f
No known key found for this signature in database
GPG Key ID: BE03111EB7ED6E2E

View File

@ -47,6 +47,10 @@ namespace microfmt {
}
#endif
template<typename U, typename V> U to(V v) {
return static_cast<U>(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<std::size_t>(1 + (63 - clz(value)) / shift);
auto n_digits = to<std::size_t>(1 + (63 - clz(value)) / shift);
std::string number;
number.resize(n_digits);
std::size_t i = n_digits - 1;