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

A class template representing a preparsed `FormatSpec`, with template arguments specifying the conversion characters used within the format string&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;auto Conv&period;&period;&period;&gt;
using ParsedFormat = absl::str&lowbar;format&lowbar;internal::ExtendedParsedFormat&lt;absl&colon;&colon;str&lowbar;format&lowbar;internal&colon;&colon;ToFormatConversionCharSet(Conv)&period;&period;&period;&gt;;
----

== Description

Such characters must be valid format type specifiers, and these type specifiers are checked at compile&hyphen;time&period;

Instances of `ParsedFormat` can be created, copied, and reused to speed up formatting loops&period; A `ParsedFormat` may either be constructed statically, or dynamically through its `New()` factory function, which only constructs a runtime object if the format is valid at that time&period;

Example&colon;

&sol;&sol; Verified at compile time&period; absl&colon;&colon;ParsedFormat&lt;&apos;s&apos;, &apos;d&apos;&gt; format&lowbar;string(&quot;Welcome to %s, Number %d!&quot;)&semi; absl&colon;&colon;StrFormat(format&lowbar;string, &quot;TheVillage&quot;, 6)&semi;

&sol;&sol; Verified at runtime&period; auto format&lowbar;runtime &equals; absl&colon;&colon;ParsedFormat&lt;&apos;d&apos;&gt;&colon;&colon;New(format&lowbar;string)&semi; if (format&lowbar;runtime) &lcub; value &equals; absl&colon;&colon;StrFormat(&ast;format&lowbar;runtime, i)&semi; &rcub; else &lcub; &period;&period;&period; error case &period;&period;&period; &rcub;

An &apos;extended&apos; format is also allowed that can specify multiple conversion characters per format argument, using a combination of `absl&colon;&colon;FormatConversionCharSet` enum values (logically a set union) via the `&verbar;` operator&period; (Single character&hyphen;based arguments are still accepted, but cannot be combined)&period; Some common conversions also have predefined enum values, such as `absl&colon;&colon;FormatConversionCharSet&colon;&colon;kIntegral`&period;

Example&colon; &sol;&sol; Extended format supports multiple conversion characters per argument, &sol;&sol; specified via a combination of `FormatConversionCharSet` enums&period; using MyFormat &equals; absl&colon;&colon;ParsedFormat&lt;absl&colon;&colon;FormatConversionCharSet&colon;&colon;d &verbar; absl&colon;&colon;FormatConversionCharSet&colon;&colon;x&gt;&semi; MyFormat GetFormat(bool use&lowbar;hex) &lcub; if (use&lowbar;hex) return MyFormat(&quot;foo %x bar&quot;)&semi; return MyFormat(&quot;foo %d bar&quot;)&semi; &rcub; &sol;&sol; `format` can be used with any value that supports &apos;d&apos; and &apos;x&apos;, &sol;&sol; like `int`&period; auto format &equals; GetFormat(use&lowbar;hex)&semi; value &equals; StringF(format, i)&semi;


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