mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-27 04:20:06 +00:00
Fix ABI compatibility (#1961)
This commit is contained in:
parent
69a84198b0
commit
425778aa67
@ -261,11 +261,19 @@ const uint64_t basic_data<T>::powers_of_10_64[] = {
|
||||
10000000000000000000ULL};
|
||||
|
||||
template <typename T>
|
||||
const uint32_t basic_data<T>::zero_or_powers_of_10_32[] = {0, 0,
|
||||
const uint32_t basic_data<T>::zero_or_powers_of_10_32[] = {0,
|
||||
FMT_POWERS_OF_10(1)};
|
||||
|
||||
template <typename T>
|
||||
const uint64_t basic_data<T>::zero_or_powers_of_10_64[] = {
|
||||
0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL),
|
||||
10000000000000000000ULL};
|
||||
|
||||
template <typename T>
|
||||
const uint32_t basic_data<T>::zero_or_powers_of_10_32_new[] = {
|
||||
0, 0, FMT_POWERS_OF_10(1)};
|
||||
|
||||
template <typename T>
|
||||
const uint64_t basic_data<T>::zero_or_powers_of_10_64_new[] = {
|
||||
0, 0, FMT_POWERS_OF_10(1), FMT_POWERS_OF_10(1000000000ULL),
|
||||
10000000000000000000ULL};
|
||||
|
||||
|
@ -866,8 +866,8 @@ template <typename T> struct FMT_EXTERN_TEMPLATE_API divtest_table_entry {
|
||||
// Static data is placed in this class template for the header-only config.
|
||||
template <typename T = void> 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<uint32_t> divtest_table_for_pow5_32[];
|
||||
@ -891,6 +891,10 @@ template <typename T = void> 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)).
|
||||
@ -917,7 +921,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.
|
||||
@ -984,7 +988,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
|
||||
|
||||
@ -3785,6 +3789,7 @@ extern template void detail::vformat_to(detail::buffer<char>&, string_view,
|
||||
basic_format_args<format_context>,
|
||||
detail::locale_ref);
|
||||
namespace detail {
|
||||
|
||||
extern template FMT_API std::string grouping_impl<char>(locale_ref loc);
|
||||
extern template FMT_API std::string grouping_impl<wchar_t>(locale_ref loc);
|
||||
extern template FMT_API char thousands_sep_impl<char>(locale_ref loc);
|
||||
|
@ -28,6 +28,31 @@ template dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
|
||||
FMT_NOEXCEPT;
|
||||
template dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
|
||||
FMT_NOEXCEPT;
|
||||
|
||||
// DEPRECATED! This function exists for ABI compatibility.
|
||||
template <typename Char>
|
||||
typename basic_format_context<std::back_insert_iterator<buffer<Char>>,
|
||||
Char>::iterator
|
||||
vformat_to(buffer<Char>& buf, basic_string_view<Char> format_str,
|
||||
basic_format_args<basic_format_context<
|
||||
std::back_insert_iterator<buffer<type_identity_t<Char>>>,
|
||||
type_identity_t<Char>>>
|
||||
args) {
|
||||
using iterator = std::back_insert_iterator<buffer<char>>;
|
||||
using context = basic_format_context<
|
||||
std::back_insert_iterator<buffer<type_identity_t<Char>>>,
|
||||
type_identity_t<Char>>;
|
||||
auto out = iterator(buf);
|
||||
format_handler<iterator, Char, context> h(out, format_str, args, {});
|
||||
parse_format_string<false>(format_str, h);
|
||||
return out;
|
||||
}
|
||||
template basic_format_context<std::back_insert_iterator<buffer<char>>,
|
||||
char>::iterator
|
||||
vformat_to(buffer<char>&, string_view,
|
||||
basic_format_args<basic_format_context<
|
||||
std::back_insert_iterator<buffer<type_identity_t<char>>>,
|
||||
type_identity_t<char>>>);
|
||||
} // namespace detail
|
||||
|
||||
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
|
||||
|
Loading…
Reference in New Issue
Block a user