diff --git a/include/fmt/printf.h b/include/fmt/printf.h index d62b0bc3..5d1aeb71 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -573,12 +573,6 @@ inline auto make_printf_args(const T&... args) return {args...}; } -/** - \rst - Constructs an `~fmt::format_arg_store` object that contains references to - arguments and can be implicitly converted to `~fmt::wprintf_args`. - \endrst - */ // DEPRECATED! template inline auto make_wprintf_args(const T&... args) @@ -586,13 +580,13 @@ inline auto make_wprintf_args(const T&... args) return {args...}; } -template > +template inline auto vsprintf( - const S& fmt, + basic_string_view fmt, basic_format_args>> args) -> std::basic_string { auto buf = basic_memory_buffer(); - detail::vprintf(buf, detail::to_string_view(fmt), args); + detail::vprintf(buf, fmt, args); return to_string(buf); } @@ -612,13 +606,13 @@ inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string { fmt::make_format_args>(args...)); } -template > +template inline auto vfprintf( - std::FILE* f, const S& fmt, + std::FILE* f, basic_string_view fmt, basic_format_args>> args) -> int { auto buf = basic_memory_buffer(); - detail::vprintf(buf, detail::to_string_view(fmt), args); + detail::vprintf(buf, fmt, args); size_t size = buf.size(); return std::fwrite(buf.data(), sizeof(Char), size, f) < size ? -1 @@ -636,9 +630,8 @@ inline auto vfprintf( */ template > inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int { - using context = basic_printf_context; return vfprintf(f, detail::to_string_view(fmt), - fmt::make_format_args(args...)); + fmt::make_format_args>(args...)); } template diff --git a/test/printf-test.cc b/test/printf-test.cc index 4ebec94f..81db9b23 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -532,8 +532,9 @@ TEST(printf_test, vprintf) { int n = 42; auto store = fmt::format_arg_store(n); auto args = fmt::basic_format_args(store); - EXPECT_EQ(fmt::vsprintf("%d", args), "42"); - EXPECT_WRITE(stdout, fmt::vfprintf(stdout, "%d", args), "42"); + EXPECT_EQ(fmt::vsprintf(fmt::string_view("%d"), args), "42"); + EXPECT_WRITE(stdout, fmt::vfprintf(stdout, fmt::string_view("%d"), args), + "42"); } template @@ -551,9 +552,9 @@ TEST(printf_test, fixed_large_exponent) { TEST(printf_test, make_printf_args) { EXPECT_EQ("[42] something happened", - fmt::vsprintf("[%d] %s happened", + fmt::vsprintf(fmt::string_view("[%d] %s happened"), {fmt::make_printf_args(42, "something")})); EXPECT_EQ(L"[42] something happened", - fmt::vsprintf(L"[%d] %s happened", + fmt::vsprintf(fmt::basic_string_view(L"[%d] %s happened"), {fmt::make_wprintf_args(42, L"something")})); }