From fbf3b943cc9a515d76956d8e766455201f11fd7d Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 7 Jul 2020 06:06:50 -0700 Subject: [PATCH] Workaround a bug in gcc --- include/fmt/core.h | 8 ++++++-- include/fmt/format.h | 4 ++-- src/format.cc | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index c33ab5c1..c4d4cfd6 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1360,6 +1360,10 @@ using buffer_context = using format_context = buffer_context; using wformat_context = buffer_context; +// Workaround a bug in gcc: https://stackoverflow.com/q/62767544/471164. +#define FMT_BUFFER_CONTEXT(Char) \ + basic_format_context>, Char> + /** \rst An array of references to arguments. It can be implicitly converted into @@ -1768,9 +1772,9 @@ std::basic_string vformat( std::string vformat(string_view format_str, format_args args); template -typename buffer_context::iterator vformat_to( +typename FMT_BUFFER_CONTEXT(Char)::iterator vformat_to( buffer& buf, basic_string_view format_str, - basic_format_args>> args); + basic_format_args)> args); template ::value)> diff --git a/include/fmt/format.h b/include/fmt/format.h index 1c0b3840..ddf086f8 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3482,9 +3482,9 @@ extern template int snprintf_float(long double value, template , FMT_ENABLE_IF(detail::is_string::value)> -inline typename buffer_context::iterator vformat_to( +inline typename FMT_BUFFER_CONTEXT(Char)::iterator vformat_to( detail::buffer& buf, const S& format_str, - basic_format_args>> args) { + basic_format_args)> args) { return detail::vformat_to(buf, to_string_view(format_str), args); } diff --git a/src/format.cc b/src/format.cc index bc06c089..a64a1f38 100644 --- a/src/format.cc +++ b/src/format.cc @@ -44,8 +44,9 @@ template FMT_API char detail::decimal_point_impl(locale_ref); template FMT_API void detail::buffer::append(const char*, const char*); -template FMT_API format_context::iterator detail::vformat_to( - detail::buffer&, string_view, basic_format_args); +template FMT_API FMT_BUFFER_CONTEXT(char)::iterator detail::vformat_to( + detail::buffer&, string_view, + basic_format_args); template FMT_API int detail::snprintf_float(double, int, detail::float_specs, detail::buffer&);