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_; }
};
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, typename Char = char>

View File

@ -186,10 +186,9 @@ void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
}
FMT_EXPORT
template <typename... Args>
void print(std::wostream& os,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
Args&&... args) {
template <typename... T>
void print(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
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
template <typename... Args>
void println(std::wostream& os,
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
Args&&... args) {
print(os, L"{}\n", fmt::format(fmt, std::forward<Args>(args)...));
template <typename... T>
void println(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
T&&... args) {
print(os, L"{}\n", fmt::format(fmt, std::forward<T>(args)...));
}
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 wmemory_buffer = basic_memory_buffer<wchar_t>;
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
// Workaround broken conversion on older gcc.
template <typename... Args> using wformat_string = wstring_view;
inline auto runtime(wstring_view s) -> wstring_view { return s; }
#else
template <typename... Args>
using wformat_string = basic_format_string<wchar_t, type_identity_t<Args>...>;
template <typename Char, typename... T>
using basic_format_string = fstring<Char, T...>;
template <typename... T>
using wformat_string = typename fstring<wchar_t, T...>::t;
inline auto runtime(wstring_view s) -> runtime_format_string<wchar_t> {
return {{s}};
}
#endif
template <> struct is_char<wchar_t> : std::true_type {};
template <> struct is_char<char16_t> : std::true_type {};