diff --git a/include/fmt/format.h b/include/fmt/format.h index 26b81e07b5ce..64ada7a3c321 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3576,6 +3576,28 @@ struct format_to_n_result { std::size_t size; }; +template +using format_to_n_context = typename fmt::format_context_t< + fmt::internal::truncating_iterator>::type; + +template +using format_to_n_args = fmt::basic_format_args>; + +template +inline format_arg_store, Args...> + make_format_to_n_args(const Args & ... args) { + return format_arg_store, Args...>(args...); +} + +template +inline format_to_n_result vformat_to_n( + OutputIt out, std::size_t n, string_view format_str, + format_to_n_args args) { + typedef internal::truncating_iterator It; + auto it = vformat_to(It(out, n), format_str, args); + return {it.base(), it.count()}; +} + /** \rst Formats arguments, writes up to ``n`` characters of the result to the output @@ -3586,10 +3608,8 @@ struct format_to_n_result { template inline format_to_n_result format_to_n( OutputIt out, std::size_t n, string_view format_str, const Args &... args) { - typedef internal::truncating_iterator It; - auto it = vformat_to(It(out, n), format_str, - make_format_args::type>(args...)); - return {it.base(), it.count()}; + return vformat_to_n(out, n, format_str, + make_format_to_n_args(args...)); } template inline format_to_n_result format_to_n(