diff --git a/include/fmt/os.h b/include/fmt/os.h index 79f1f896..d1f753a7 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 ffe33d67..44a2988f 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");