diff --git a/ostd/stream.hh b/ostd/stream.hh index 5ce1dd7..d1e47cf 100644 --- a/ostd/stream.hh +++ b/ostd/stream.hh @@ -110,24 +110,11 @@ struct stream { } } - template - void write(T const &v); + template + void write(A const &...args); - template - void write(T const &v, A const &...args) { - write(v); - write(args...); - } - - template - void writeln(T const &v) { - write(v); - put_char('\n'); - } - - template - void writeln(T const &v, A const &...args) { - write(v); + template + void writeln(A const &...args) { write(args...); put_char('\n'); } @@ -319,19 +306,19 @@ private: }; template -stream_line_range stream::iter_lines(bool keep_nl) { +inline stream_line_range stream::iter_lines(bool keep_nl) { return stream_line_range{*this, keep_nl}; } -template -inline void stream::write(T const &v) { - format_spec{'s', p_loc}.format_value(iter(), v); +template +inline void stream::write(A const &...args) { + format_spec sp{'s', p_loc}; + (sp.format_value(iter(), args), ...); } template inline void stream::writef(string_range fmt, A const &...args) { - format_spec sp{fmt, p_loc}; - sp.format(iter(), args...); + format_spec{fmt, p_loc}.format(iter(), args...); } }