diff --git a/include/fmt/color.h b/include/fmt/color.h index 8cddbfe1..62636dc9 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -594,7 +594,7 @@ template format_str, basic_format_args>> args) { - decltype(detail::get_buffer(out)) buf(detail::get_buffer_init(out)); + detail::get_buffer_t buf(detail::get_buffer(out)); detail::vformat_to(buf, ts, format_str, args); return detail::get_iterator(buf); } diff --git a/include/fmt/core.h b/include/fmt/core.h index 9fb25ba4..a176566f 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -924,11 +924,12 @@ using buffer_appender = conditional_t::value, appender, std::back_insert_iterator>>; // Maps an output iterator to a buffer. -template -auto get_buffer(OutputIt) -> iterator_buffer; -template auto get_buffer(buffer_appender) -> buffer&; +template +using get_buffer_t = + conditional_t>::value, buffer&, + iterator_buffer>; -template auto get_buffer_init(OutputIt out) -> OutputIt { +template auto get_buffer(OutputIt out) -> OutputIt { return out; } @@ -1339,7 +1340,7 @@ FMT_END_DETAIL_NAMESPACE class appender : public std::back_insert_iterator> { using base = std::back_insert_iterator>; - friend auto get_buffer_init(appender out) -> detail::buffer& { + friend auto get_buffer(appender out) -> detail::buffer& { return detail::get_container(out); } @@ -2847,8 +2848,8 @@ FMT_INLINE auto format(format_string fmt, T&&... args) -> std::string { template ::value)> auto vformat_to(OutputIt out, string_view fmt, format_args args) -> OutputIt { - using detail::get_buffer_init; - decltype(detail::get_buffer(out)) buf(get_buffer_init(out)); + using detail::get_buffer; + detail::get_buffer_t buf(get_buffer(out)); detail::vformat_to(buf, string_view(fmt), args); return detail::get_iterator(buf); } diff --git a/include/fmt/format.h b/include/fmt/format.h index b59a1865..d205e760 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2695,7 +2695,7 @@ template , auto vformat_to(OutputIt out, const S& format_str, basic_format_args>> args) -> OutputIt { - decltype(detail::get_buffer(out)) buf(detail::get_buffer_init(out)); + detail::get_buffer_t buf(detail::get_buffer(out)); detail::vformat_to(buf, to_string_view(format_str), args); return detail::get_iterator(buf); } diff --git a/include/fmt/locale.h b/include/fmt/locale.h index e79140a1..8b62319e 100644 --- a/include/fmt/locale.h +++ b/include/fmt/locale.h @@ -47,7 +47,7 @@ template >> args) { - decltype(detail::get_buffer(out)) buf(detail::get_buffer_init(out)); + detail::get_buffer_t buf(detail::get_buffer(out)); vformat_to(buf, to_string_view(format_str), args, detail::locale_ref(loc)); return detail::get_iterator(buf); }