diff --git a/include/fmt/format.h b/include/fmt/format.h index 6548f716..3a9cf9b3 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -163,6 +163,14 @@ FMT_END_NAMESPACE # define FMT_USE_LONG_DOUBLE 1 #endif +// 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 + // __builtin_clz is broken in clang with Microsoft CodeGen: // https://github.com/fmtlib/fmt/issues/519 #if (FMT_GCC_VERSION || FMT_HAS_BUILTIN(__builtin_clz)) && !FMT_MSC_VER @@ -738,12 +746,19 @@ FMT_CONSTEXPR bool is_supported_floating_point(T) { (std::is_same::value && FMT_USE_LONG_DOUBLE); } +#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>>; +#endif // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data {