diff --git a/include/fmt/core.h b/include/fmt/core.h index a3afc53c73474..322fd99db60c9 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1901,12 +1901,7 @@ using is_formattable = bool_constant -class format_arg_store_impl -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 - // Workaround a GCC template argument substitution bug. - : public basic_format_args -#endif -{ +class format_arg_store_impl { private: static const size_t num_args = sizeof...(Args); static const bool is_packed = num_args <= detail::max_packed_args; @@ -1923,11 +1918,7 @@ class format_arg_store_impl public: template FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args) - : -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 - basic_format_args(*this), -#endif - args_{value_type(named_args_, NUM_NAMED_ARGS), + : args_{value_type(named_args_, NUM_NAMED_ARGS), detail::make_arg(args)...} { detail::init_named_args(named_args_, 0, 0, args...); } @@ -1944,13 +1935,9 @@ class format_arg_store_impl } }; +// A specialization of format_arg_store_impl without named arguments. template -class format_arg_store_impl -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 - // Workaround a GCC template argument substitution bug. - : public basic_format_args -#endif -{ +class format_arg_store_impl { private: static const size_t num_args = sizeof...(Args); static const bool is_packed = num_args <= detail::max_packed_args; @@ -1964,12 +1951,7 @@ class format_arg_store_impl public: template FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args) - : -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 - basic_format_args(*this), -#endif - args_{detail::make_arg(args)...} { - } + : args_{detail::make_arg(args)...} {} static constexpr unsigned long long desc = (is_packed ? detail::encode_types() @@ -1986,10 +1968,10 @@ using format_arg_store = /** \rst - Constructs a `~fmt::format_arg_store` object that contains references to - arguments and can be implicitly converted to `~fmt::format_args`. `Context` - can be omitted in which case it defaults to `~fmt::format_context`. - See `~fmt::arg` for lifetime considerations. + Constructs an object that stores references to arguments and can be implicitly + converted to `~fmt::format_args`. `Context` can be omitted in which case it + defaults to `~fmt::format_context`. See `~fmt::arg` for lifetime + considerations. \endrst */ // Take arguments by lvalue references to avoid some lifetime issues, e.g. @@ -2739,7 +2721,8 @@ template <> struct vformat_args { using type = format_args; }; -// Use vformat_args and avoid type_identity to keep symbols short. +// Use vformat_args and avoid type_identity, keep symbols short and workaround +// a GCC <= 4.8 bug. template void vformat_to(buffer& buf, basic_string_view fmt, typename vformat_args::type args, locale_ref loc = {}); diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 9906e5f22c731..389949e7401d0 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -193,7 +193,7 @@ inline void vprint_directly(std::ostream& os, string_view format_str, FMT_EXPORT template void vprint(std::basic_ostream& os, basic_string_view> format_str, - basic_format_args>> args) { + typename detail::vformat_args::type args) { auto buffer = basic_memory_buffer(); detail::vformat_to(buffer, format_str, args); if (detail::write_ostream_unicode(os, {buffer.data(), buffer.size()})) return; diff --git a/include/fmt/printf.h b/include/fmt/printf.h index fbf3f6f1b6bb7..b2861123e3aad 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -586,10 +586,13 @@ inline auto make_wprintf_args(const T&... args) return {args...}; } +template struct vprintf_args { + using type = basic_format_args>; +}; + template -inline auto vsprintf( - basic_string_view fmt, - basic_format_args>> args) +inline auto vsprintf(basic_string_view fmt, + typename vprintf_args::type args) -> std::basic_string { auto buf = basic_memory_buffer(); detail::vprintf(buf, fmt, args); diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index df5ad2afa3a42..704ea3571993c 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -128,7 +128,7 @@ auto join(const std::tuple& tuple, basic_string_view sep) template ::value)> auto vformat(basic_string_view format_str, - basic_format_args>> args) + typename detail::vformat_args::type args) -> std::basic_string { auto buf = basic_memory_buffer(); detail::vformat_to(buf, format_str, args);