diff --git a/include/fmt/format.h b/include/fmt/format.h index e056c583..1ad0d7ac 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2355,10 +2355,6 @@ FMT_CONSTEXPR auto parse_align(const Char* begin, const Char* end, return begin; } -struct float_specs { - sign_t sign : 8; -}; - template FMT_CONSTEXPR20 auto write_nonfinite(OutputIt out, bool isnan, format_specs specs, sign_t sign) @@ -2484,13 +2480,11 @@ FMT_CONSTEXPR20 auto write_significand(OutputIt out, T significand, template > FMT_CONSTEXPR20 auto do_write_float(OutputIt out, const DecimalFP& f, - const format_specs& specs, - float_specs fspecs, locale_ref loc) - -> OutputIt { + const format_specs& specs, sign_t sign, + locale_ref loc) -> OutputIt { auto significand = f.significand; int significand_size = get_significand_size(f); const Char zero = static_cast('0'); - auto sign = fspecs.sign; size_t size = to_unsigned(significand_size) + (sign ? 1 : 0); using iterator = reserve_iterator; @@ -2605,14 +2599,14 @@ template class fallback_digit_grouping { template 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 { if (is_constant_evaluated()) { return do_write_float>(out, f, specs, fspecs, + fallback_digit_grouping>(out, f, specs, sign, loc); } else { - return do_write_float(out, f, specs, fspecs, loc); + return do_write_float(out, f, specs, sign, loc); } } @@ -3487,9 +3481,7 @@ FMT_CONSTEXPR20 auto write_float(OutputIt out, T value, format_specs specs, return write_nonfinite(out, detail::isnan(value), specs, sign); if (specs.align == align::numeric && sign) { - auto it = reserve(out, 1); - *it++ = detail::sign(sign); - out = base_iterator(out, it); + *out++ = detail::sign(sign); sign = sign::none; 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, std::is_same(), buffer); - float_specs fspecs = float_specs(); - fspecs.sign = sign; specs.precision = precision; auto f = big_decimal_fp{buffer.data(), static_cast(buffer.size()), exp}; - return write_float(out, f, specs, fspecs, loc); + return write_float(out, f, specs, sign, loc); } template OutputIt { if ((bit_cast(value) & mask) == mask) return write_nonfinite(out, std::isnan(value), specs, sign); - auto fspecs = float_specs(); - fspecs.sign = sign; auto dec = dragonbox::to_decimal(static_cast(value)); - return write_float(out, dec, specs, fspecs, {}); + return write_float(out, dec, specs, sign, {}); } template