diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index e3b3490c..5d466eeb 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -261,11 +261,19 @@ const uint64_t basic_data::powers_of_10_64[] = { 10000000000000000000ULL}; template -const uint32_t basic_data::zero_or_powers_of_10_32[] = {0, 0, +const uint32_t basic_data::zero_or_powers_of_10_32[] = {0, FMT_POWERS_OF_10(1)}; - template const uint64_t basic_data::zero_or_powers_of_10_64[] = { + 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), + 10000000000000000000ULL}; + +template +const uint32_t basic_data::zero_or_powers_of_10_32_new[] = { + 0, 0, FMT_POWERS_OF_10(1)}; + +template +const uint64_t basic_data::zero_or_powers_of_10_64_new[] = { 0, 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL), 10000000000000000000ULL}; diff --git a/include/fmt/format.h b/include/fmt/format.h index 5d90f443..da121cbd 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -868,8 +868,8 @@ template struct FMT_EXTERN_TEMPLATE_API divtest_table_entry { // Static data is placed in this class template for the header-only config. template struct FMT_EXTERN_TEMPLATE_API basic_data { static const uint64_t powers_of_10_64[]; - static const uint32_t zero_or_powers_of_10_32[]; - static const uint64_t zero_or_powers_of_10_64[]; + static const uint32_t zero_or_powers_of_10_32_new[]; + static const uint64_t zero_or_powers_of_10_64_new[]; static const uint64_t grisu_pow10_significands[]; static const int16_t grisu_pow10_exponents[]; static const divtest_table_entry divtest_table_for_pow5_32[]; @@ -893,6 +893,10 @@ template struct FMT_EXTERN_TEMPLATE_API basic_data { static const char signs[]; static const char left_padding_shifts[5]; static const char right_padding_shifts[5]; + + // DEPRECATED! These are for ABI compatibility. + static const uint32_t zero_or_powers_of_10_32[]; + static const uint64_t zero_or_powers_of_10_64[]; }; // Maps bsr(n) to ceil(log10(pow(2, bsr(n) + 1) - 1)). @@ -919,7 +923,7 @@ struct data : basic_data<> {}; inline int count_digits(uint64_t n) { // https://github.com/fmtlib/format-benchmark/blob/master/digits10 auto t = bsr2log10(FMT_BUILTIN_CLZLL(n | 1) ^ 63); - return t - (n < data::zero_or_powers_of_10_64[t]); + return t - (n < data::zero_or_powers_of_10_64_new[t]); } #else // Fallback version of count_digits used when __builtin_clz is not available. @@ -986,7 +990,7 @@ template <> int count_digits<4>(detail::fallback_uintptr n); // Optional version of count_digits for better performance on 32-bit platforms. inline int count_digits(uint32_t n) { auto t = bsr2log10(FMT_BUILTIN_CLZ(n | 1) ^ 31); - return t - (n < data::zero_or_powers_of_10_32[t]); + return t - (n < data::zero_or_powers_of_10_32_new[t]); } #endif @@ -3787,6 +3791,7 @@ extern template void detail::vformat_to(detail::buffer&, string_view, basic_format_args, detail::locale_ref); namespace detail { + extern template FMT_API std::string grouping_impl(locale_ref loc); extern template FMT_API std::string grouping_impl(locale_ref loc); extern template FMT_API char thousands_sep_impl(locale_ref loc); diff --git a/src/format.cc b/src/format.cc index 88565e60..bca87b03 100644 --- a/src/format.cc +++ b/src/format.cc @@ -28,6 +28,31 @@ template dragonbox::decimal_fp dragonbox::to_decimal(float x) FMT_NOEXCEPT; template dragonbox::decimal_fp dragonbox::to_decimal(double x) FMT_NOEXCEPT; + +// DEPRECATED! This function exists for ABI compatibility. +template +typename basic_format_context>, + Char>::iterator +vformat_to(buffer& buf, basic_string_view format_str, + basic_format_args>>, + type_identity_t>> + args) { + using iterator = std::back_insert_iterator>; + using context = basic_format_context< + std::back_insert_iterator>>, + type_identity_t>; + auto out = iterator(buf); + format_handler h(out, format_str, args, {}); + parse_format_string(format_str, h); + return out; +} +template basic_format_context>, + char>::iterator +vformat_to(buffer&, string_view, + basic_format_args>>, + type_identity_t>>); } // namespace detail template struct FMT_INSTANTIATION_DEF_API detail::basic_data;