mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Deprecate wide printf
This commit is contained in:
@ -585,6 +585,7 @@ inline auto make_printf_args(const T&... args)
|
|||||||
arguments and can be implicitly converted to `~fmt::wprintf_args`.
|
arguments and can be implicitly converted to `~fmt::wprintf_args`.
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
|
// DEPRECATED!
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
inline auto make_wprintf_args(const T&... args)
|
inline auto make_wprintf_args(const T&... args)
|
||||||
-> format_arg_store<wprintf_context, T...> {
|
-> format_arg_store<wprintf_context, T...> {
|
||||||
@ -647,12 +648,12 @@ inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
|
|||||||
fmt::make_format_args<context>(args...));
|
fmt::make_format_args<context>(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename Char = char_t<S>>
|
template <typename Char>
|
||||||
inline auto vprintf(
|
FMT_DEPRECATED inline auto vprintf(
|
||||||
const S& fmt,
|
basic_string_view<Char> fmt,
|
||||||
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args)
|
basic_format_args<basic_printf_context_t<type_identity_t<Char>>> args)
|
||||||
-> int {
|
-> int {
|
||||||
return vfprintf(stdout, detail::to_string_view(fmt), args);
|
return vfprintf(stdout, fmt, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -664,11 +665,14 @@ inline auto vprintf(
|
|||||||
fmt::printf("Elapsed time: %.2f seconds", 1.23);
|
fmt::printf("Elapsed time: %.2f seconds", 1.23);
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename S, typename... T, FMT_ENABLE_IF(detail::is_string<S>::value)>
|
template <typename... T>
|
||||||
inline auto printf(const S& fmt, const T&... args) -> int {
|
inline auto printf(string_view fmt, const T&... args) -> int {
|
||||||
return vprintf(
|
return vfprintf(stdout, fmt, make_printf_args(args...));
|
||||||
detail::to_string_view(fmt),
|
}
|
||||||
fmt::make_format_args<basic_printf_context_t<char_t<S>>>(args...));
|
template <typename... T>
|
||||||
|
FMT_DEPRECATED inline auto printf(basic_string_view<wchar_t> fmt,
|
||||||
|
const T&... args) -> int {
|
||||||
|
return vfprintf(stdout, fmt, make_wprintf_args(args...));
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_END_EXPORT
|
FMT_END_EXPORT
|
||||||
|
@ -533,7 +533,6 @@ TEST(printf_test, vprintf) {
|
|||||||
auto store = fmt::format_arg_store<fmt::printf_context, int>(n);
|
auto store = fmt::format_arg_store<fmt::printf_context, int>(n);
|
||||||
auto args = fmt::basic_format_args<fmt::printf_context>(store);
|
auto args = fmt::basic_format_args<fmt::printf_context>(store);
|
||||||
EXPECT_EQ(fmt::vsprintf("%d", args), "42");
|
EXPECT_EQ(fmt::vsprintf("%d", args), "42");
|
||||||
EXPECT_WRITE(stdout, fmt::vprintf("%d", args), "42");
|
|
||||||
EXPECT_WRITE(stdout, fmt::vfprintf(stdout, "%d", args), "42");
|
EXPECT_WRITE(stdout, fmt::vfprintf(stdout, "%d", args), "42");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user