From c5ebecf7c6e036c75fbe13f9a8432cfeec2963bb Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Fri, 30 Mar 2018 08:31:41 -1000 Subject: [PATCH] Document format_to_n --- doc/api.rst | 3 +++ include/fmt/format.h | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/api.rst b/doc/api.rst index 5d9db7dd..62c731ad 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -135,6 +135,9 @@ Output iterator support ----------------------- .. doxygenfunction:: fmt::format_to(OutputIt, string_view, const Args&...) +.. doxygenfunction:: fmt::format_to_n(OutputIt, size_t string_view, const Args&...) +.. doxygenstruct:: fmt::format_to_n_result + :members: Literal-based API ----------------- diff --git a/include/fmt/format.h b/include/fmt/format.h index f6b37f4d..b293c530 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -3256,7 +3256,7 @@ struct format_handler : internal::error_handler { basic_arg arg; }; -/** Formats arguments and writes the output to the buffer. */ +/** Formats arguments and writes the output to the range. */ template typename Context::iterator vformat_to(typename ArgFormatter::range out, basic_string_view format_str, @@ -3419,10 +3419,19 @@ inline typename std::enable_if< template struct format_to_n_result { + /** Iterator past the end of the output range. */ OutputIt out; + /** Total (not truncated) output size. */ std::size_t size; }; +/** + \rst + Formats arguments, writes up to ``n`` characters of the result to the output + iterator ``out`` and returns the total output size and the iterator past the end + of the output range. + \endrst + */ template inline format_to_n_result format_to_n( OutputIt out, std::size_t n, string_view format_str, const Args & ... args) {