mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 02:37:36 +02:00
Remove float_specs
This commit is contained in:
@ -2355,10 +2355,6 @@ FMT_CONSTEXPR auto parse_align(const Char* begin, const Char* end,
|
|||||||
return begin;
|
return begin;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct float_specs {
|
|
||||||
sign_t sign : 8;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Char, typename OutputIt>
|
template <typename Char, typename OutputIt>
|
||||||
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan,
|
FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan,
|
||||||
format_specs specs, sign_t sign)
|
format_specs specs, sign_t sign)
|
||||||
@ -2484,13 +2480,11 @@ FMT_CONSTEXPR20 auto write_significand(OutputIt out, T significand,
|
|||||||
template <typename Char, typename OutputIt, typename DecimalFP,
|
template <typename Char, typename OutputIt, typename DecimalFP,
|
||||||
typename Grouping = digit_grouping<Char>>
|
typename Grouping = digit_grouping<Char>>
|
||||||
FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& f,
|
FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& f,
|
||||||
const format_specs& specs,
|
const format_specs& specs, sign_t sign,
|
||||||
float_specs fspecs, locale_ref loc)
|
locale_ref loc) -> OutputIt {
|
||||||
-> OutputIt {
|
|
||||||
auto significand = f.significand;
|
auto significand = f.significand;
|
||||||
int significand_size = get_significand_size(f);
|
int significand_size = get_significand_size(f);
|
||||||
const Char zero = static_cast<Char>('0');
|
const Char zero = static_cast<Char>('0');
|
||||||
auto sign = fspecs.sign;
|
|
||||||
size_t size = to_unsigned(significand_size) + (sign ? 1 : 0);
|
size_t size = to_unsigned(significand_size) + (sign ? 1 : 0);
|
||||||
using iterator = reserve_iterator<OutputIt>;
|
using iterator = reserve_iterator<OutputIt>;
|
||||||
|
|
||||||
@ -2605,14 +2599,14 @@ template <typename Char> class fallback_digit_grouping {
|
|||||||
|
|
||||||
template <typename Char, typename OutputIt, typename DecimalFP>
|
template <typename Char, typename OutputIt, typename DecimalFP>
|
||||||
FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP& f,
|
FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP& f,
|
||||||
const format_specs& specs, float_specs fspecs,
|
const format_specs& specs, sign_t sign,
|
||||||
locale_ref loc) -> OutputIt {
|
locale_ref loc) -> OutputIt {
|
||||||
if (is_constant_evaluated()) {
|
if (is_constant_evaluated()) {
|
||||||
return do_write_float<Char, OutputIt, DecimalFP,
|
return do_write_float<Char, OutputIt, DecimalFP,
|
||||||
fallback_digit_grouping<Char>>(out, f, specs, fspecs,
|
fallback_digit_grouping<Char>>(out, f, specs, sign,
|
||||||
loc);
|
loc);
|
||||||
} else {
|
} else {
|
||||||
return do_write_float<Char>(out, f, specs, fspecs, loc);
|
return do_write_float<Char>(out, f, specs, sign, loc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3487,9 +3481,7 @@ FMT_CONSTEXPR20 auto write_float(OutputIt out, T value, format_specs specs,
|
|||||||
return write_nonfinite<Char>(out, detail::isnan(value), specs, sign);
|
return write_nonfinite<Char>(out, detail::isnan(value), specs, sign);
|
||||||
|
|
||||||
if (specs.align == align::numeric && sign) {
|
if (specs.align == align::numeric && sign) {
|
||||||
auto it = reserve(out, 1);
|
*out++ = detail::sign<Char>(sign);
|
||||||
*it++ = detail::sign<Char>(sign);
|
|
||||||
out = base_iterator(out, it);
|
|
||||||
sign = sign::none;
|
sign = sign::none;
|
||||||
if (specs.width != 0) --specs.width;
|
if (specs.width != 0) --specs.width;
|
||||||
}
|
}
|
||||||
@ -3520,11 +3512,9 @@ FMT_CONSTEXPR20 auto write_float(OutputIt out, T value, format_specs specs,
|
|||||||
int exp = format_float(convert_float(value), precision, specs,
|
int exp = format_float(convert_float(value), precision, specs,
|
||||||
std::is_same<T, float>(), buffer);
|
std::is_same<T, float>(), buffer);
|
||||||
|
|
||||||
float_specs fspecs = float_specs();
|
|
||||||
fspecs.sign = sign;
|
|
||||||
specs.precision = precision;
|
specs.precision = precision;
|
||||||
auto f = big_decimal_fp{buffer.data(), static_cast<int>(buffer.size()), exp};
|
auto f = big_decimal_fp{buffer.data(), static_cast<int>(buffer.size()), exp};
|
||||||
return write_float<Char>(out, f, specs, fspecs, loc);
|
return write_float<Char>(out, f, specs, sign, loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename OutputIt, typename T,
|
template <typename Char, typename OutputIt, typename T,
|
||||||
@ -3556,10 +3546,8 @@ FMT_CONSTEXPR20 auto write(OutputIt out, T value) -> OutputIt {
|
|||||||
if ((bit_cast<floaty_uint>(value) & mask) == mask)
|
if ((bit_cast<floaty_uint>(value) & mask) == mask)
|
||||||
return write_nonfinite<Char>(out, std::isnan(value), specs, sign);
|
return write_nonfinite<Char>(out, std::isnan(value), specs, sign);
|
||||||
|
|
||||||
auto fspecs = float_specs();
|
|
||||||
fspecs.sign = sign;
|
|
||||||
auto dec = dragonbox::to_decimal(static_cast<floaty>(value));
|
auto dec = dragonbox::to_decimal(static_cast<floaty>(value));
|
||||||
return write_float<Char>(out, dec, specs, fspecs, {});
|
return write_float<Char>(out, dec, specs, sign, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename OutputIt, typename T,
|
template <typename Char, typename OutputIt, typename T,
|
||||||
|
Reference in New Issue
Block a user