diff --git a/fmt/printf.h b/fmt/printf.h index a41d61ba..038b9f26 100644 --- a/fmt/printf.h +++ b/fmt/printf.h @@ -517,10 +517,15 @@ void PrintfFormatter::format(BasicCStringRef format_str) { write(writer_, start, s); } -template -void printf(BasicWriter &w, BasicCStringRef format, ArgList args) { - PrintfFormatter(args, w).format(format); +inline void printf(Writer &w, CStringRef format, ArgList args) { + PrintfFormatter(args, w).format(format); } +FMT_VARIADIC(void, printf, Writer &, CStringRef) + +inline void printf(WWriter &w, WCStringRef format, ArgList args) { + PrintfFormatter(args, w).format(format); +} +FMT_VARIADIC(void, printf, WWriter &, WCStringRef) /** \rst diff --git a/test/printf-test.cc b/test/printf-test.cc index 4d8dc756..7d9e21dd 100644 --- a/test/printf-test.cc +++ b/test/printf-test.cc @@ -500,3 +500,9 @@ TEST(PrintfTest, OStream) { EXPECT_EQ("Don't panic!", os.str()); EXPECT_EQ(12, ret); } + +TEST(PrintfTest, Writer) { + fmt::MemoryWriter writer; + printf(writer, "%d", 42); + EXPECT_EQ("42", writer.str()); +}