mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-07 08:31:16 +00:00
Simplify ostream_params
This commit is contained in:
parent
2a47a1e48f
commit
734344931f
@ -358,21 +358,20 @@ struct buffer_size {
|
|||||||
struct ostream_params {
|
struct ostream_params {
|
||||||
int oflag = file::WRONLY | file::CREATE;
|
int oflag = file::WRONLY | file::CREATE;
|
||||||
size_t buffer_size = BUFSIZ;
|
size_t buffer_size = BUFSIZ;
|
||||||
|
|
||||||
|
ostream_params() {}
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
ostream_params(T... params, int oflag) : ostream_params(params...) {
|
||||||
|
this->oflag = oflag;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename... T>
|
||||||
|
ostream_params(T... params, detail::buffer_size bs)
|
||||||
|
: ostream_params(params...) {
|
||||||
|
this->buffer_size = bs.value;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void get_params(ostream_params&) {}
|
|
||||||
|
|
||||||
template <typename... T>
|
|
||||||
inline void get_params(ostream_params& op, int oflag, T... params) {
|
|
||||||
op.oflag = oflag;
|
|
||||||
get_params(op, params...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... T>
|
|
||||||
inline void get_params(ostream_params& op, buffer_size bs, T... params) {
|
|
||||||
op.buffer_size = bs.value;
|
|
||||||
get_params(op, params...);
|
|
||||||
}
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
static constexpr detail::buffer_size buffer_size;
|
static constexpr detail::buffer_size buffer_size;
|
||||||
@ -435,9 +434,7 @@ class ostream : private detail::buffer<char> {
|
|||||||
*/
|
*/
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
inline ostream output_file(cstring_view path, T... params) {
|
inline ostream output_file(cstring_view path, T... params) {
|
||||||
auto op = detail::ostream_params();
|
return {path, detail::ostream_params(params...)};
|
||||||
get_params(op, params...);
|
|
||||||
return {path, op};
|
|
||||||
}
|
}
|
||||||
#endif // FMT_USE_FCNTL
|
#endif // FMT_USE_FCNTL
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user