[#BloombergLP-bslfmt-format_to_n-0b]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslfmt.adoc[bslfmt]::format&lowbar;to&lowbar;n
:relfileprefix: ../../
:mrdocs:

Format `args` per `fmtStr` into `out`, writing at most `maxNumChars`&period;

== Synopsis

Declared in `&lt;bslfmt&lowbar;format&lowbar;imp&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class t&lowbar;OUT,
    class&period;&period;&period; t&lowbar;ARGS&gt;
format&lowbar;to&lowbar;n&lowbar;result&lt;t&lowbar;OUT&gt;
format&lowbar;to&lowbar;n(
    t&lowbar;OUT out,
    bsl::iterator&lowbar;traits&lt;t&lowbar;OUT&gt;::difference&lowbar;type maxNumChars,
    xref:BloombergLP/bslfmt/format_string.adoc[bslfmt::format&lowbar;string&lt;t&lowbar;ARGS&period;&period;&period;&gt;] fmtStr,
    t&lowbar;ARGS const&&period;&period;&period; 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&period; Return a `format&lowbar;to&lowbar;n&lowbar;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&period; In the event of an error the exception `format&lowbar;error` is thrown&period; Behavior is undefined if `out` does not point to a valid output iterator&period;

== Return Value

a `format&lowbar;to&lowbar;n&lowbar;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]#
