Skip to content

Commit e2b7238

Browse files
committed
Cleanup format string API
1 parent 1e0c6cd commit e2b7238

3 files changed

Lines changed: 12 additions & 20 deletions

File tree

include/fmt/base.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,9 +2806,6 @@ template <typename Char, typename... T> class fstring {
28062806
auto get() const -> basic_string_view<Char> { return str_; }
28072807
};
28082808

2809-
template <typename Char, typename... T>
2810-
using basic_format_string = typename fstring<Char, T...>::t;
2811-
28122809
template <typename... T> using format_string = typename fstring<char, T...>::t;
28132810

28142811
template <typename T, typename Char = char>

include/fmt/ostream.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ void print(std::ostream& os, format_string<T...> fmt, T&&... args) {
186186
}
187187

188188
FMT_EXPORT
189-
template <typename... Args>
190-
void print(std::wostream& os,
191-
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
192-
Args&&... args) {
189+
template <typename... T>
190+
void print(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
191+
T&&... args) {
193192
vprint(os, fmt, fmt::make_format_args<buffered_context<wchar_t>>(args...));
194193
}
195194

@@ -199,11 +198,10 @@ void println(std::ostream& os, format_string<T...> fmt, T&&... args) {
199198
}
200199

201200
FMT_EXPORT
202-
template <typename... Args>
203-
void println(std::wostream& os,
204-
basic_format_string<wchar_t, type_identity_t<Args>...> fmt,
205-
Args&&... args) {
206-
print(os, L"{}\n", fmt::format(fmt, std::forward<Args>(args)...));
201+
template <typename... T>
202+
void println(std::wostream& os, typename fstring<wchar_t, T...>::t fmt,
203+
T&&... args) {
204+
print(os, L"{}\n", fmt::format(fmt, std::forward<T>(args)...));
207205
}
208206

209207
FMT_END_NAMESPACE

include/fmt/xchar.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,14 @@ using wformat_context = buffered_context<wchar_t>;
6464
using wformat_args = basic_format_args<wformat_context>;
6565
using wmemory_buffer = basic_memory_buffer<wchar_t>;
6666

67-
#if FMT_GCC_VERSION && FMT_GCC_VERSION < 409
68-
// Workaround broken conversion on older gcc.
69-
template <typename... Args> using wformat_string = wstring_view;
70-
inline auto runtime(wstring_view s) -> wstring_view { return s; }
71-
#else
72-
template <typename... Args>
73-
using wformat_string = basic_format_string<wchar_t, type_identity_t<Args>...>;
67+
template <typename Char, typename... T>
68+
using basic_format_string = fstring<Char, T...>;
69+
70+
template <typename... T>
71+
using wformat_string = typename fstring<wchar_t, T...>::t;
7472
inline auto runtime(wstring_view s) -> runtime_format_string<wchar_t> {
7573
return {{s}};
7674
}
77-
#endif
7875

7976
template <> struct is_char<wchar_t> : std::true_type {};
8077
template <> struct is_char<char16_t> : std::true_type {};

0 commit comments

Comments
 (0)