diff --git a/include/fmt/format.h b/include/fmt/format.h index 1dd9e26b..83437f63 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1680,18 +1680,24 @@ template struct write_int_data { // Writes an integer in the format // -// where are written by f(it). -template -FMT_CONSTEXPR OutputIt write_int(OutputIt out, int num_digits, - string_view prefix, - const basic_format_specs& specs, F f) { +// where are written by write_digits(it). +template +FMT_CONSTEXPR FMT_INLINE OutputIt +write_int(OutputIt out, int num_digits, string_view prefix, + const basic_format_specs& specs, W write_digits) { + if (specs.width == 0 && specs.precision < 0) { + auto it = reserve(out, to_unsigned(num_digits) + prefix.size()); + if (prefix.size() != 0) + it = copy_str(prefix.begin(), prefix.end(), it); + return base_iterator(out, write_digits(it)); + } auto data = write_int_data(num_digits, prefix, specs); return write_padded( out, specs, data.size, [=](reserve_iterator it) { if (prefix.size() != 0) it = copy_str(prefix.begin(), prefix.end(), it); it = detail::fill_n(it, data.padding, static_cast('0')); - return f(it); + return write_digits(it); }); }