Cleanup format string API

This commit is contained in:
Victor Zverovich 2024-09-03 21:30:57 -07:00
parent 1e0c6cdc3b
commit e2b7238707
3 changed files with 12 additions and 20 deletions

View File

@ -2806,9 +2806,6 @@ template <typename Char, typename... T> class fstring {
auto get() const -> basic_string_view<Char> { return str_; } auto get() const -> basic_string_view<Char> { return str_; }
}; };
template <typename Char, typename... T>
using basic_format_string = typename fstring<Char, T...>::t;
template <typename... T> using format_string = typename fstring<char, T...>::t; template <typename... T> using format_string = typename fstring<char, T...>::t;
template <typename T, typename Char = char> template <typename T, typename Char = char>

View File

@ -186,10 +186,9 @@ void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
} }
FMT_EXPORT FMT_EXPORT
template <typename... Args> template <typename... T>
void print(std::wostream& os, void print(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt, T&&... args) {
Args&&... args) {
vprint(os, fmt, fmt::make_format_args<buffered_context<wchar_t>>(args...)); vprint(os, fmt, fmt::make_format_args<buffered_context<wchar_t>>(args...));
} }
@ -199,11 +198,10 @@ void println(std::ostream& os, format_string<T...> fmt, T&&... args) {
} }
FMT_EXPORT FMT_EXPORT
template <typename... Args> template <typename... T>
void println(std::wostream& os, void println(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt, T&&... args) {
Args&&... args) { print(os, L"{}\n", fmt::format(fmt, std::forward<T>(args)...));
print(os, L"{}\n", fmt::format(fmt, std::forward<Args>(args)...));
} }
FMT_END_NAMESPACE FMT_END_NAMESPACE

View File

@ -64,17 +64,14 @@ using wformat_context = buffered_context<wchar_t>;
using wformat_args = basic_format_args<wformat_context>; using wformat_args = basic_format_args<wformat_context>;
using wmemory_buffer = basic_memory_buffer<wchar_t>; using wmemory_buffer = basic_memory_buffer<wchar_t>;
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409 template <typename Char, typename... T>
// Workaround broken conversion on older gcc. using basic_format_string = fstring<Char, T...>;
template <typename... Args> using wformat_string = wstring_view;
inline auto runtime(wstring_view s) -> wstring_view { return s; } template <typename... T>
#else using wformat_string = typename fstring<wchar_t, T...>::t;
template <typename... Args>
using wformat_string = basic_format_string<wchar_t, type_identity_t<Args>...>;
inline auto runtime(wstring_view s) -> runtime_format_string<wchar_t> { inline auto runtime(wstring_view s) -> runtime_format_string<wchar_t> {
return {{s}}; return {{s}};
} }
#endif
template <> struct is_char<wchar_t> : std::true_type {}; template <> struct is_char<wchar_t> : std::true_type {};
template <> struct is_char<char16_t> : std::true_type {}; template <> struct is_char<char16_t> : std::true_type {};