[#absl-StrFormat] = xref:absl.adoc[absl]::StrFormat :relfileprefix: ../ :mrdocs: Returns a `string` given a `printf()`‐style format string and zero or more additional arguments. == Synopsis Declared in `<absl/strings/str_format.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- template<typename... Args> [[nodiscard]] std::string StrFormat( xref:absl/FormatSpec.adoc[FormatSpec<Args...>] const& format, Args const&... args); ---- == Description Use it as you would `sprintf()`. `StrFormat()` is the primary formatting function within the `str_format` library, and should be used in most cases where you need type‐safe conversion of types into formatted strings. The format string generally consists of ordinary character data along with one or more format conversion specifiers (denoted by the `%` character). Ordinary character data is returned unchanged into the result string, while each conversion specification performs a type substitution from `StrFormat()`'s other arguments. See the comments for `FormatSpec` for full information on the makeup of this format string. Example: std::string s = absl::StrFormat( "Welcome to %s, Number %d!", "The Village", 6); EXPECT_EQ("Welcome to The Village, Number 6!", s); Returns an empty string in case of error. == Return Value The formatted string, or an empty string on error. [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. | *args* | The arguments substituted into the format string. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#