[#BloombergLP-bslfmt-format_to_n-0b] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslfmt.adoc[bslfmt]::format_to_n :relfileprefix: ../../ :mrdocs: Format `args` per `fmtStr` into `out`, writing at most `maxNumChars`. == Synopsis Declared in `<bslfmt_format_imp.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template< class t_OUT, class... t_ARGS> format_to_n_result<t_OUT> format_to_n( t_OUT out, bsl::iterator_traits<t_OUT>::difference_type maxNumChars, xref:BloombergLP/bslfmt/format_string.adoc[bslfmt::format_string<t_ARGS...>] fmtStr, t_ARGS const&... args); ---- == Description Format the specified `args` according to the specification given by the specified `fmtStr`, and write at most the specified `maxNumChars` characters of the result of this operation into the output iterator referenced by the specified `out` parameter. Return a `format_to_n_result` object whose `size` member holds the number of characters that would have been written to `out` were such writing not truncated, and whose `out` member holds an iterator one past the end of the output range. In the event of an error the exception `format_error` is thrown. Behavior is undefined if `out` does not point to a valid output iterator. == Return Value a `format_to_n_result` with the output iterator and untruncated size == Parameters [cols="1,4"] |=== | Name| Description | *out* | output iterator receiving formatted characters | *maxNumChars* | maximum number of characters to write | *fmtStr* | format string | *args* | values to format |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#