From e2b723870787da77c040f5e705882121d618aaef Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 3 Sep 2024 21:30:57 -0700 Subject: [PATCH] Cleanup format string API --- include/fmt/base.h | 3 --- include/fmt/ostream.h | 16 +++++++--------- include/fmt/xchar.h | 13 +++++-------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/include/fmt/base.h b/include/fmt/base.h index 6dd9dda0..9bb9f633 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -2806,9 +2806,6 @@ template class fstring { auto get() const -> basic_string_view { return str_; } }; -template -using basic_format_string = typename fstring::t; - template using format_string = typename fstring::t; template diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index e7f6caa2..2102f910 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -186,10 +186,9 @@ void print(std::ostream& os, format_string fmt, T&&... args) { } FMT_EXPORT -template -void print(std::wostream& os, - basic_format_string...> fmt, - Args&&... args) { +template +void print(std::wostream& os, typename fstring::t fmt, + T&&... args) { vprint(os, fmt, fmt::make_format_args>(args...)); } @@ -199,11 +198,10 @@ void println(std::ostream& os, format_string fmt, T&&... args) { } FMT_EXPORT -template -void println(std::wostream& os, - basic_format_string...> fmt, - Args&&... args) { - print(os, L"{}\n", fmt::format(fmt, std::forward(args)...)); +template +void println(std::wostream& os, typename fstring::t fmt, + T&&... args) { + print(os, L"{}\n", fmt::format(fmt, std::forward(args)...)); } FMT_END_NAMESPACE diff --git a/include/fmt/xchar.h b/include/fmt/xchar.h index 2c2c882c..0fb95244 100644 --- a/include/fmt/xchar.h +++ b/include/fmt/xchar.h @@ -64,17 +64,14 @@ using wformat_context = buffered_context; using wformat_args = basic_format_args; using wmemory_buffer = basic_memory_buffer; -#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 -// Workaround broken conversion on older gcc. -template using wformat_string = wstring_view; -inline auto runtime(wstring_view s) -> wstring_view { return s; } -#else -template -using wformat_string = basic_format_string...>; +template +using basic_format_string = fstring; + +template +using wformat_string = typename fstring::t; inline auto runtime(wstring_view s) -> runtime_format_string { return {{s}}; } -#endif template <> struct is_char : std::true_type {}; template <> struct is_char : std::true_type {};