From fa43fd144425343a1b26030bc2adba2f2e11156d Mon Sep 17 00:00:00 2001 From: Daumantas Kavolis <12998363+dkavolis@users.noreply.github.com> Date: Sun, 20 Dec 2020 15:14:54 +0000 Subject: [PATCH] Forward arguments to work with views (#2068) --- include/fmt/os.h | 5 +++-- test/os-test.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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");