diff --git a/include/fmt/os.h b/include/fmt/os.h index 79f1f8966a17..d1f753a79516 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -411,8 +411,9 @@ class ostream final : private detail::buffer { } template - void print(const S& format_str, const Args&... args) { - format_to(detail::buffer_appender(*this), format_str, args...); + void print(const S& format_str, Args&&... args) { + format_to(detail::buffer_appender(*this), format_str, + std::forward(args)...); } }; diff --git a/test/os-test.cc b/test/os-test.cc index ffe33d673f29..44a2988fb9c5 100644 --- a/test/os-test.cc +++ b/test/os-test.cc @@ -295,7 +295,7 @@ TEST(OStreamTest, Move) { TEST(OStreamTest, Print) { fmt::ostream out = fmt::output_file("test-file"); - out.print("The answer is {}.\n", 42); + out.print("The answer is {}.\n", fmt::join(std::initializer_list{42}, ", ")); out.close(); file in("test-file", file::RDONLY); EXPECT_READ(in, "The answer is 42.\n");