Skip to content

Commit

Permalink
Forward arguments to work with views (#2068)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkavolis authored Dec 20, 2020
1 parent 3551f5d commit fa43fd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/fmt/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ class ostream final : private detail::buffer<char> {
}

template <typename S, typename... Args>
void print(const S& format_str, const Args&... args) {
format_to(detail::buffer_appender<char>(*this), format_str, args...);
void print(const S& format_str, Args&&... args) {
format_to(detail::buffer_appender<char>(*this), format_str,
std::forward<Args>(args)...);
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/os-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>{42}, ", "));
out.close();
file in("test-file", file::RDONLY);
EXPECT_READ(in, "The answer is 42.\n");
Expand Down

0 comments on commit fa43fd1

Please sign in to comment.