diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index ee5a8c27..848d3722 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -579,8 +579,7 @@ struct chrono_formatter { void write(Rep value, int width) { write_sign(); if (isnan(value)) return write_nan(); - typedef typename int_traits::main_type main_type; - main_type n = to_unsigned( + uint32_or_64_t n = to_unsigned( to_nonnegative_int(value, (std::numeric_limits::max)())); int num_digits = internal::count_digits(n); if (width > num_digits) out = std::fill_n(out, width - num_digits, '0'); diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index b60149fa..2343575b 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -157,8 +157,7 @@ FMT_FUNC void format_error_code(internal::buffer& out, int error_code, static const char ERROR_STR[] = "error "; // Subtract 2 to account for terminating null characters in SEP and ERROR_STR. std::size_t error_code_size = sizeof(SEP) + sizeof(ERROR_STR) - 2; - typedef internal::int_traits::main_type main_type; - main_type abs_value = static_cast(error_code); + auto abs_value = static_cast>(error_code); if (internal::is_negative(error_code)) { abs_value = 0 - abs_value; ++error_code_size; diff --git a/include/fmt/format.h b/include/fmt/format.h index 44389e8e..62418fb3 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -606,12 +606,11 @@ FMT_CONSTEXPR bool is_negative(T) { return false; } -template struct int_traits { - // Smallest of uint32_t and uint64_t that is large enough to represent - // all values of T. - using main_type = - conditional_t::digits <= 32, uint32_t, uint64_t>; -}; +// Smallest of uint32_t and uint64_t that is large enough to represent all +// values of T. +template +using uint32_or_64_t = + conditional_t::digits <= 32, uint32_t, uint64_t>; // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data { @@ -1273,8 +1272,7 @@ template class basic_writer { // Writes a decimal integer. template void write_decimal(Int value) { - typedef typename internal::int_traits::main_type main_type; - main_type abs_value = static_cast(value); + auto abs_value = static_cast>(value); bool is_negative = internal::is_negative(value); if (is_negative) abs_value = 0 - abs_value; int num_digits = internal::count_digits(abs_value); @@ -1286,7 +1284,7 @@ template class basic_writer { // The handle_int_type_spec handler that writes an integer. template struct int_writer { - typedef typename internal::int_traits::main_type unsigned_type; + using unsigned_type = uint32_or_64_t; basic_writer& writer; const Spec& spec; diff --git a/include/fmt/printf.h b/include/fmt/printf.h index c2e9f9bf..fbca84ad 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -158,8 +158,7 @@ template class printf_width_handler { template ::value)> unsigned operator()(T value) { - typedef typename internal::int_traits::main_type UnsignedType; - UnsignedType width = static_cast(value); + auto width = static_cast>(value); if (internal::is_negative(value)) { spec_.align_ = ALIGN_LEFT; width = 0 - width;