diff options
author | Victor Zverovich <viz@fb.com> | 2020-07-07 06:06:50 -0700 |
---|---|---|
committer | Victor Zverovich <viz@fb.com> | 2020-07-07 06:06:50 -0700 |
commit | fbf3b943cc9a515d76956d8e766455201f11fd7d (patch) | |
tree | 2b02e15691bc66c5157293712699290e523ce923 | |
parent | a29a01d304328fc56baa5aa450458c4cd945c966 (diff) | |
download | fmtlib-fbf3b943cc9a515d76956d8e766455201f11fd7d.tar.gz |
Workaround a bug in gcc
-rw-r--r-- | include/fmt/core.h | 8 | ||||
-rw-r--r-- | include/fmt/format.h | 4 | ||||
-rw-r--r-- | 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<char>; using wformat_context = buffer_context<wchar_t>; +// Workaround a bug in gcc: https://stackoverflow.com/q/62767544/471164. +#define FMT_BUFFER_CONTEXT(Char) \ + basic_format_context<std::back_insert_iterator<detail::buffer<Char>>, Char> + /** \rst An array of references to arguments. It can be implicitly converted into @@ -1768,9 +1772,9 @@ std::basic_string<Char> vformat( std::string vformat(string_view format_str, format_args args); template <typename Char> -typename buffer_context<Char>::iterator vformat_to( +typename FMT_BUFFER_CONTEXT(Char)::iterator vformat_to( buffer<Char>& buf, basic_string_view<Char> format_str, - basic_format_args<buffer_context<type_identity_t<Char>>> args); + basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> args); template <typename Char, typename Args, FMT_ENABLE_IF(!std::is_same<Char, char>::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>(long double value, template <typename S, typename Char = char_t<S>, FMT_ENABLE_IF(detail::is_string<S>::value)> -inline typename buffer_context<Char>::iterator vformat_to( +inline typename FMT_BUFFER_CONTEXT(Char)::iterator vformat_to( detail::buffer<Char>& buf, const S& format_str, - basic_format_args<buffer_context<type_identity_t<Char>>> args) { + basic_format_args<FMT_BUFFER_CONTEXT(type_identity_t<Char>)> 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<char>::append(const char*, const char*); -template FMT_API format_context::iterator detail::vformat_to( - detail::buffer<char>&, string_view, basic_format_args<format_context>); +template FMT_API FMT_BUFFER_CONTEXT(char)::iterator detail::vformat_to( + detail::buffer<char>&, string_view, + basic_format_args<FMT_BUFFER_CONTEXT(char)>); template FMT_API int detail::snprintf_float(double, int, detail::float_specs, detail::buffer<char>&); |