From 734344931ffd552cab200e7132c479442853fbef Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 1 Aug 2020 15:47:11 -0700 Subject: [PATCH] Simplify ostream_params --- include/fmt/os.h | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/include/fmt/os.h b/include/fmt/os.h index 24e51052..bb6503a8 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -358,21 +358,20 @@ struct buffer_size { struct ostream_params { int oflag = file::WRONLY | file::CREATE; size_t buffer_size = BUFSIZ; + + ostream_params() {} + + template + ostream_params(T... params, int oflag) : ostream_params(params...) { + this->oflag = oflag; + } + + template + ostream_params(T... params, detail::buffer_size bs) + : ostream_params(params...) { + this->buffer_size = bs.value; + } }; - -inline void get_params(ostream_params&) {} - -template -inline void get_params(ostream_params& op, int oflag, T... params) { - op.oflag = oflag; - get_params(op, params...); -} - -template -inline void get_params(ostream_params& op, buffer_size bs, T... params) { - op.buffer_size = bs.value; - get_params(op, params...); -} } // namespace detail static constexpr detail::buffer_size buffer_size; @@ -435,9 +434,7 @@ class ostream : private detail::buffer { */ template inline ostream output_file(cstring_view path, T... params) { - auto op = detail::ostream_params(); - get_params(op, params...); - return {path, op}; + return {path, detail::ostream_params(params...)}; } #endif // FMT_USE_FCNTL