mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-27 06:35:37 +00:00
Forward arguments to work with views (#2068)
This commit is contained in:
parent
3551f5d118
commit
fa43fd1444
@ -411,8 +411,9 @@ class ostream final : private detail::buffer<char> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename S, typename... Args>
|
template <typename S, typename... Args>
|
||||||
void print(const S& format_str, const Args&... args) {
|
void print(const S& format_str, Args&&... args) {
|
||||||
format_to(detail::buffer_appender<char>(*this), format_str, args...);
|
format_to(detail::buffer_appender<char>(*this), format_str,
|
||||||
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ TEST(OStreamTest, Move) {
|
|||||||
|
|
||||||
TEST(OStreamTest, Print) {
|
TEST(OStreamTest, Print) {
|
||||||
fmt::ostream out = fmt::output_file("test-file");
|
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();
|
out.close();
|
||||||
file in("test-file", file::RDONLY);
|
file in("test-file", file::RDONLY);
|
||||||
EXPECT_READ(in, "The answer is 42.\n");
|
EXPECT_READ(in, "The answer is 42.\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user