diff --git a/include/fmt/format.h b/include/fmt/format.h index e31829e4..58512bd5 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1482,16 +1482,21 @@ OutputIt write_bytes(OutputIt out, string_view bytes, } template -FMT_CONSTEXPR OutputIt write(OutputIt out, Char value, - const basic_format_specs& specs, - locale_ref loc = {}) { - if (specs.type && specs.type != 'c') - return write(out, static_cast(value), specs, loc); +FMT_CONSTEXPR OutputIt write_char(OutputIt out, Char value, + const basic_format_specs& specs) { return write_padded(out, specs, 1, [=](reserve_iterator it) { *it++ = value; return it; }); } +template +FMT_CONSTEXPR OutputIt write(OutputIt out, Char value, + const basic_format_specs& specs, + locale_ref loc = {}) { + return !specs.type || specs.type == 'c' + ? write_char(out, value, specs) + : write(out, static_cast(value), specs, loc); +} // Data for write_int that doesn't depend on output iterator type. It is used to // avoid template code bloat. @@ -1662,7 +1667,7 @@ FMT_CONSTEXPR OutputIt write(OutputIt out, T value, }); } case 'c': - return write(out, static_cast(abs_value), specs); + return write_char(out, static_cast(abs_value), specs); default: FMT_THROW(format_error("invalid type specifier")); }