[#absl-StrFormat]
= xref:absl.adoc[absl]::StrFormat
:relfileprefix: ../
:mrdocs:

Returns a `string` given a `printf()`&hyphen;style format string and zero or more additional arguments&period;

== Synopsis

Declared in `&lt;absl&sol;strings&sol;str&lowbar;format&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;typename&period;&period;&period; Args&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
std::string
StrFormat(
    xref:absl/FormatSpec.adoc[FormatSpec&lt;Args&period;&period;&period;&gt;] const& format,
    Args const&&period;&period;&period; args);
----

== Description

Use it as you would `sprintf()`&period; `StrFormat()` is the primary formatting function within the `str&lowbar;format` library, and should be used in most cases where you need type&hyphen;safe conversion of types into formatted strings&period;

The format string generally consists of ordinary character data along with one or more format conversion specifiers (denoted by the `%` character)&period; Ordinary character data is returned unchanged into the result string, while each conversion specification performs a type substitution from `StrFormat()`&apos;s other arguments&period; See the comments for `FormatSpec` for full information on the makeup of this format string&period;

Example&colon;

std&colon;&colon;string s &equals; absl&colon;&colon;StrFormat( &quot;Welcome to %s, Number %d!&quot;, &quot;The Village&quot;, 6)&semi; EXPECT&lowbar;EQ(&quot;Welcome to The Village, Number 6!&quot;, s)&semi;

Returns an empty string in case of error&period;

== Return Value

The formatted string, or an empty string on error&period;

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *format*
| The format string&period;
| *args*
| The arguments substituted into the format string&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
