Remove legacy workaround

This commit is contained in:
Victor Zverovich
2024-01-08 19:20:10 -08:00
parent c177324ba9
commit 6af30d8f75
5 changed files with 33 additions and 52 deletions

View File

@ -1901,12 +1901,7 @@ using is_formattable = bool_constant<!std::is_base_of<
\endrst \endrst
*/ */
template <typename Context, size_t NUM_NAMED_ARGS, typename... Args> template <typename Context, size_t NUM_NAMED_ARGS, typename... Args>
class format_arg_store_impl class format_arg_store_impl {
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
// Workaround a GCC template argument substitution bug.
: public basic_format_args<Context>
#endif
{
private: private:
static const size_t num_args = sizeof...(Args); static const size_t num_args = sizeof...(Args);
static const bool is_packed = num_args <= detail::max_packed_args; static const bool is_packed = num_args <= detail::max_packed_args;
@ -1923,11 +1918,7 @@ class format_arg_store_impl
public: public:
template <typename... T> template <typename... T>
FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args) FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args)
: : args_{value_type(named_args_, NUM_NAMED_ARGS),
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
basic_format_args<Context>(*this),
#endif
args_{value_type(named_args_, NUM_NAMED_ARGS),
detail::make_arg<is_packed, Context>(args)...} { detail::make_arg<is_packed, Context>(args)...} {
detail::init_named_args(named_args_, 0, 0, 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 <typename Context, typename... Args> template <typename Context, typename... Args>
class format_arg_store_impl<Context, 0, Args...> class format_arg_store_impl<Context, 0, Args...> {
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
// Workaround a GCC template argument substitution bug.
: public basic_format_args<Context>
#endif
{
private: private:
static const size_t num_args = sizeof...(Args); static const size_t num_args = sizeof...(Args);
static const bool is_packed = num_args <= detail::max_packed_args; static const bool is_packed = num_args <= detail::max_packed_args;
@ -1964,12 +1951,7 @@ class format_arg_store_impl<Context, 0, Args...>
public: public:
template <typename... T> template <typename... T>
FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args) FMT_CONSTEXPR FMT_INLINE format_arg_store_impl(T&... args)
: : args_{detail::make_arg<is_packed, Context>(args)...} {}
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
basic_format_args<Context>(*this),
#endif
args_{detail::make_arg<is_packed, Context>(args)...} {
}
static constexpr unsigned long long desc = static constexpr unsigned long long desc =
(is_packed ? detail::encode_types<Context, Args...>() (is_packed ? detail::encode_types<Context, Args...>()
@ -1986,10 +1968,10 @@ using format_arg_store =
/** /**
\rst \rst
Constructs a `~fmt::format_arg_store` object that contains references to Constructs an object that stores references to arguments and can be implicitly
arguments and can be implicitly converted to `~fmt::format_args`. `Context` converted to `~fmt::format_args`. `Context` can be omitted in which case it
can be omitted in which case it defaults to `~fmt::format_context`. defaults to `~fmt::format_context`. See `~fmt::arg` for lifetime
See `~fmt::arg` for lifetime considerations. considerations.
\endrst \endrst
*/ */
// Take arguments by lvalue references to avoid some lifetime issues, e.g. // Take arguments by lvalue references to avoid some lifetime issues, e.g.
@ -2739,7 +2721,8 @@ template <> struct vformat_args<char> {
using type = format_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 <typename Char> template <typename Char>
void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt, void vformat_to(buffer<Char>& buf, basic_string_view<Char> fmt,
typename vformat_args<Char>::type args, locale_ref loc = {}); typename vformat_args<Char>::type args, locale_ref loc = {});

View File

@ -3969,7 +3969,7 @@ template <typename Char> struct udl_arg {
template <typename Locale, typename Char> template <typename Locale, typename Char>
auto vformat(const Locale& loc, basic_string_view<Char> fmt, auto vformat(const Locale& loc, basic_string_view<Char> fmt,
basic_format_args<buffer_context<type_identity_t<Char>>> args) typename detail::vformat_args<Char>::type args)
-> std::basic_string<Char> { -> std::basic_string<Char> {
auto buf = basic_memory_buffer<Char>(); auto buf = basic_memory_buffer<Char>();
detail::vformat_to(buf, fmt, args, detail::locale_ref(loc)); detail::vformat_to(buf, fmt, args, detail::locale_ref(loc));

View File

@ -193,7 +193,7 @@ inline void vprint_directly(std::ostream& os, string_view format_str,
FMT_EXPORT template <typename Char> FMT_EXPORT template <typename Char>
void vprint(std::basic_ostream<Char>& os, void vprint(std::basic_ostream<Char>& os,
basic_string_view<type_identity_t<Char>> format_str, basic_string_view<type_identity_t<Char>> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) { typename detail::vformat_args<Char>::type args) {
auto buffer = basic_memory_buffer<Char>(); auto buffer = basic_memory_buffer<Char>();
detail::vformat_to(buffer, format_str, args); detail::vformat_to(buffer, format_str, args);
if (detail::write_ostream_unicode(os, {buffer.data(), buffer.size()})) return; if (detail::write_ostream_unicode(os, {buffer.data(), buffer.size()})) return;

View File

@ -586,10 +586,13 @@ inline auto make_wprintf_args(const T&... args)
return {args...}; return {args...};
} }
template <typename Char> struct vprintf_args {
using type = basic_format_args<basic_printf_context<Char>>;
};
template <typename Char> template <typename Char>
inline auto vsprintf( inline auto vsprintf(basic_string_view<Char> fmt,
basic_string_view<Char> fmt, typename vprintf_args<Char>::type args)
basic_format_args<basic_printf_context<type_identity_t<Char>>> args)
-> std::basic_string<Char> { -> std::basic_string<Char> {
auto buf = basic_memory_buffer<Char>(); auto buf = basic_memory_buffer<Char>();
detail::vprintf(buf, fmt, args); detail::vprintf(buf, fmt, args);
@ -612,10 +615,8 @@ inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
} }
template <typename Char> template <typename Char>
inline auto vfprintf( inline auto vfprintf(std::FILE* f, basic_string_view<Char> fmt,
std::FILE* f, basic_string_view<Char> fmt, typename vprintf_args<Char>::type args) -> int {
basic_format_args<basic_printf_context<type_identity_t<Char>>> args)
-> int {
auto buf = basic_memory_buffer<Char>(); auto buf = basic_memory_buffer<Char>();
detail::vprintf(buf, fmt, args); detail::vprintf(buf, fmt, args);
size_t size = buf.size(); size_t size = buf.size();
@ -640,9 +641,8 @@ inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
} }
template <typename Char> template <typename Char>
FMT_DEPRECATED inline auto vprintf( FMT_DEPRECATED inline auto vprintf(basic_string_view<Char> fmt,
basic_string_view<Char> fmt, typename vprintf_args<Char>::type args)
basic_format_args<basic_printf_context<type_identity_t<Char>>> args)
-> int { -> int {
return vfprintf(stdout, fmt, args); return vfprintf(stdout, fmt, args);
} }

View File

@ -128,7 +128,7 @@ auto join(const std::tuple<T...>& tuple, basic_string_view<wchar_t> sep)
template <typename Char, FMT_ENABLE_IF(!std::is_same<Char, char>::value)> template <typename Char, FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
auto vformat(basic_string_view<Char> format_str, auto vformat(basic_string_view<Char> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) typename detail::vformat_args<Char>::type args)
-> std::basic_string<Char> { -> std::basic_string<Char> {
auto buf = basic_memory_buffer<Char>(); auto buf = basic_memory_buffer<Char>();
detail::vformat_to(buf, format_str, args); detail::vformat_to(buf, format_str, args);
@ -155,9 +155,8 @@ template <typename Locale, typename S,
typename Char = detail::format_string_char_t<S>, typename Char = detail::format_string_char_t<S>,
FMT_ENABLE_IF(detail::is_locale<Locale>::value&& FMT_ENABLE_IF(detail::is_locale<Locale>::value&&
detail::is_exotic_char<Char>::value)> detail::is_exotic_char<Char>::value)>
inline auto vformat( inline auto vformat(const Locale& loc, const S& format_str,
const Locale& loc, const S& format_str, typename detail::vformat_args<Char>::type args)
basic_format_args<buffer_context<type_identity_t<Char>>> args)
-> std::basic_string<Char> { -> std::basic_string<Char> {
return detail::vformat(loc, detail::to_string_view(format_str), args); return detail::vformat(loc, detail::to_string_view(format_str), args);
} }
@ -177,8 +176,7 @@ template <typename OutputIt, typename S,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&& FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
detail::is_exotic_char<Char>::value)> detail::is_exotic_char<Char>::value)>
auto vformat_to(OutputIt out, const S& format_str, auto vformat_to(OutputIt out, const S& format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) typename detail::vformat_args<Char>::type args) -> OutputIt {
-> OutputIt {
auto&& buf = detail::get_buffer<Char>(out); auto&& buf = detail::get_buffer<Char>(out);
detail::vformat_to(buf, detail::to_string_view(format_str), args); detail::vformat_to(buf, detail::to_string_view(format_str), args);
return detail::get_iterator(buf, out); return detail::get_iterator(buf, out);
@ -198,9 +196,9 @@ template <typename Locale, typename S, typename OutputIt, typename... Args,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&& FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
detail::is_locale<Locale>::value&& detail::is_locale<Locale>::value&&
detail::is_exotic_char<Char>::value)> detail::is_exotic_char<Char>::value)>
inline auto vformat_to( inline auto vformat_to(OutputIt out, const Locale& loc, const S& format_str,
OutputIt out, const Locale& loc, const S& format_str, typename detail::vformat_args<Char>::type args)
basic_format_args<buffer_context<type_identity_t<Char>>> args) -> OutputIt { -> OutputIt {
auto&& buf = detail::get_buffer<Char>(out); auto&& buf = detail::get_buffer<Char>(out);
vformat_to(buf, detail::to_string_view(format_str), args, vformat_to(buf, detail::to_string_view(format_str), args,
detail::locale_ref(loc)); detail::locale_ref(loc));
@ -222,9 +220,9 @@ inline auto format_to(OutputIt out, const Locale& loc, const S& format_str,
template <typename OutputIt, typename Char, typename... Args, template <typename OutputIt, typename Char, typename... Args,
FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&& FMT_ENABLE_IF(detail::is_output_iterator<OutputIt, Char>::value&&
detail::is_exotic_char<Char>::value)> detail::is_exotic_char<Char>::value)>
inline auto vformat_to_n( inline auto vformat_to_n(OutputIt out, size_t n,
OutputIt out, size_t n, basic_string_view<Char> format_str, basic_string_view<Char> format_str,
basic_format_args<buffer_context<type_identity_t<Char>>> args) typename detail::vformat_args<Char>::type args)
-> format_to_n_result<OutputIt> { -> format_to_n_result<OutputIt> {
using traits = detail::fixed_buffer_traits; using traits = detail::fixed_buffer_traits;
auto buf = detail::iterator_buffer<OutputIt, Char, traits>(out, n); auto buf = detail::iterator_buffer<OutputIt, Char, traits>(out, n);