diff --git a/include/fmt/core.h b/include/fmt/core.h index ec7a946c..ad2511e9 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -311,8 +311,12 @@ struct int128_t {}; struct uint128_t {}; #endif -#if !defined(FMT_USE_SMALLEST_INT) -#define FMT_USE_SMALLEST_INT 1 +// Defining FMT_REDUCE_INT_INSTANTIATIONS to 1, will reduce the number of +// int_writer template instances to just one by only using the largest integer +// type. This results in a reduction in binary size but will cause a decrease in +// integer formatting performance. +#if !defined(FMT_REDUCE_INT_INSTANTIATIONS) +# define FMT_REDUCE_INT_INSTANTIATIONS 0 #endif // Casts a nonnegative integer to unsigned. diff --git a/include/fmt/format.h b/include/fmt/format.h index 81ce7b96..ff233b7d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -726,18 +726,18 @@ FMT_CONSTEXPR bool is_supported_floating_point(T) { (std::is_same::value && FMT_USE_LONG_DOUBLE); } -#if FMT_USE_SMALLEST_INT +#if FMT_REDUCE_INT_INSTANTIATIONS +// Pick the largest integer container to represent all values of T. +template +using uint32_or_64_or_128_t = + conditional_t; +#else // Smallest of uint32_t, uint64_t, uint128_t that is large enough to // represent all values of T. template using uint32_or_64_or_128_t = conditional_t< std::numeric_limits::digits <= 32, uint32_t, conditional_t::digits <= 64, uint64_t, uint128_t>>; -#else -// Pick the largest integer container to represent represent all values of T. -template -using uint32_or_64_or_128_t = - conditional_t; #endif // Static data is placed in this class template for the header-only config.