diff --git a/include/fmt/format.h b/include/fmt/format.h index 0d3ecd1b..6c8cf153 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3544,17 +3544,24 @@ FMT_CONSTEXPR internal::udl_arg operator"" _a(const wchar_t* s, #endif // FMT_USE_USER_DEFINED_LITERALS FMT_END_NAMESPACE -#define FMT_STRING_IMPL(s, ...) \ - []() -> fmt::basic_string_view> { \ - /* Use a macro-like name to avoid shadowing warnings. */ \ - struct FMT_COMPILE_STRING : fmt::compile_string { \ - __VA_ARGS__ FMT_CONSTEXPR \ - operator fmt::basic_string_view>() const { \ - /* FMT_STRING only accepts string literals. */ \ - return fmt::internal::literal_to_view(s); \ - } \ - }; \ - return FMT_COMPILE_STRING(); \ +#if FMT_GCC_VERSION >= 900 +# define FMT_STRING_RESULT(s) ()->fmt::basic_string_view> +#else +# define FMT_STRING_RESULT(s) +#endif + +#define FMT_STRING_IMPL(s, ...) \ + [] FMT_STRING_RESULT(s) { \ + /* Use a macro-like name to avoid shadowing warnings. */ \ + struct FMT_COMPILE_STRING : fmt::compile_string { \ + using char_type = fmt::remove_cvref_t; \ + __VA_ARGS__ FMT_CONSTEXPR \ + operator fmt::basic_string_view() const { \ + /* FMT_STRING only accepts string literals. */ \ + return fmt::internal::literal_to_view(s); \ + } \ + }; \ + return FMT_COMPILE_STRING(); \ }() /**