Remove extern format_float

This commit is contained in:
Victor Zverovich 2022-05-29 12:37:09 -07:00
parent 7e63b600b6
commit d1026fa5d2
3 changed files with 25 additions and 38 deletions

View File

@ -132,32 +132,6 @@ template <typename F> inline bool operator==(basic_fp<F> x, basic_fp<F> y) {
return x.f == y.f && x.e == y.e;
}
inline FMT_CONSTEXPR20 uint128_fallback& uint128_fallback::operator+=(
uint64_t n) noexcept {
if (is_constant_evaluated()) {
lo_ += n;
hi_ += (lo_ < n ? 1 : 0);
return *this;
}
#if FMT_HAS_BUILTIN(__builtin_addcll)
unsigned long long carry;
lo_ = __builtin_addcll(lo_, n, 0, &carry);
hi_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64)
unsigned long long result;
auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
lo_ = result;
hi_ += carry;
#elif defined(_MSC_VER) && defined(_M_X64)
auto carry = _addcarry_u64(0, lo_, n, &lo_);
_addcarry_u64(carry, hi_, 0, &hi_);
#else
lo_ += n;
hi_ += (lo_ < n ? 1 : 0);
#endif
return *this;
}
// Compilers should be able to optimize this into the ror instruction.
FMT_CONSTEXPR inline uint32_t rotr(uint32_t n, uint32_t r) noexcept {
r &= 31;

View File

@ -401,7 +401,31 @@ class uint128_fallback {
lo_ = new_lo;
hi_ = new_hi;
}
FMT_CONSTEXPR20 uint128_fallback& operator+=(uint64_t n) noexcept;
FMT_CONSTEXPR20 uint128_fallback& operator+=(uint64_t n) noexcept {
if (is_constant_evaluated()) {
lo_ += n;
hi_ += (lo_ < n ? 1 : 0);
return *this;
}
#if FMT_HAS_BUILTIN(__builtin_addcll)
unsigned long long carry;
lo_ = __builtin_addcll(lo_, n, 0, &carry);
hi_ += carry;
#elif FMT_HAS_BUILTIN(__builtin_ia32_addcarryx_u64)
unsigned long long result;
auto carry = __builtin_ia32_addcarryx_u64(0, lo_, n, &result);
lo_ = result;
hi_ += carry;
#elif defined(_MSC_VER) && defined(_M_X64)
auto carry = _addcarry_u64(0, lo_, n, &lo_);
_addcarry_u64(carry, hi_, 0, &hi_);
#else
lo_ += n;
hi_ += (lo_ < n ? 1 : 0);
#endif
return *this;
}
};
using uint128_t = conditional_t<FMT_USE_INT128, uint128_opt, uint128_fallback>;
@ -4113,12 +4137,6 @@ extern template FMT_API auto thousands_sep_impl<wchar_t>(locale_ref)
-> thousands_sep_result<wchar_t>;
extern template FMT_API auto decimal_point_impl(locale_ref) -> char;
extern template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;
extern template auto format_float<double>(double value, int precision,
float_specs specs, buffer<char>& buf)
-> int;
extern template auto format_float<long double>(long double value, int precision,
float_specs specs,
buffer<char>& buf) -> int;
#endif // FMT_HEADER_ONLY
FMT_END_DETAIL_NAMESPACE

View File

@ -35,11 +35,6 @@ template FMT_API void vformat_to(buffer<char>&, string_view,
basic_format_args<FMT_BUFFER_CONTEXT(char)>,
locale_ref);
template FMT_API auto format_float(double, int, float_specs, buffer<char>&)
-> int;
template FMT_API auto format_float(long double, int, detail::float_specs,
buffer<char>&) -> int;
// Explicit instantiations for wchar_t.
template FMT_API auto thousands_sep_impl(locale_ref)