[format.string]
# 28 Text processing library [[text]](./#text)
## 28.5 Formatting [[format]](format#string)
### 28.5.2 Format string [format.string]
#### [28.5.2.1](#general) General [[format.string.general]](format.string.general)
[1](#general-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L5914)
A [*format string*](#def:format_string "28.5.2.1 General [format.string.general]") for arguments args is
a (possibly empty) sequence of[*replacement fields*](#def:replacement_field,format_string "28.5.2.1 General [format.string.general]"),[*escape sequences*](#def:escape_sequence,format_string "28.5.2.1 General [format.string.general]"),
and characters other than { and }[.](#general-1.sentence-1)
Let charT be the character type of the format string[.](#general-1.sentence-2)
Each character that is not part of
a replacement field or an escape sequence
is copied unchanged to the output[.](#general-1.sentence-3)
An escape sequence is one of {{ or }}[.](#general-1.sentence-4)
It is replaced with { or }, respectively, in the output[.](#general-1.sentence-5)
The syntax of replacement fields is as follows:
replacement-field :
{ arg-idopt format-specifieropt }
arg-id :
0
positive-integer
positive-integer :
[*nonzero-digit*](lex.icon#nt:nonzero-digit "5.13.2 Integer literals [lex.icon]")
positive-integer [*digit*](lex.name#nt:digit "5.11 Identifiers [lex.name]")
nonnegative-integer :
[*digit*](lex.name#nt:digit "5.11 Identifiers [lex.name]")
nonnegative-integer [*digit*](lex.name#nt:digit "5.11 Identifiers [lex.name]")
[*nonzero-digit*](lex.icon#nt:nonzero-digit "5.13.2 Integer literals [lex.icon]") : one of
1 2 3 4 5 6 7 8 9
[*digit*](lex.name#nt:digit "5.11 Identifiers [lex.name]") : one of
0 1 2 3 4 5 6 7 8 9
format-specifier :
: format-spec
format-spec :
as specified by the formatter specialization for the argument type; cannot start with }
[2](#general-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L5972)
The *arg-id* field specifies the index of
the argument in args whose value is to be formatted and inserted into the output
instead of the replacement field[.](#general-2.sentence-1)
If there is no argument with
the index *arg-id* in args,
the string is not a format string for args[.](#general-2.sentence-2)
The optional *format-specifier* field
explicitly specifies a format for the replacement value[.](#general-2.sentence-3)
[3](#general-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L5983)
[*Example [1](#general-example-1)*: string s = format("{0}-{{", 8); // value of s is "8-{" â *end example*]
[4](#general-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L5990)
If all *arg-id**s* in a format string are omitted
(including those in the *format-spec*,
as interpreted by the corresponding formatter specialization),
argument indices 0, 1, 2, … will automatically be used in that order[.](#general-4.sentence-1)
If some *arg-id**s* are omitted and some are present,
the string is not a format string[.](#general-4.sentence-2)
[*Note [1](#general-note-1)*:
A format string cannot contain a
mixture of automatic and manual indexing[.](#general-4.sentence-3)
â *end note*]
[*Example [2](#general-example-2)*: string s0 = format("{} to {}", "a", "b"); // OK, automatic indexing string s1 = format("{1} to {0}", "a", "b"); // OK, manual indexing string s2 = format("{0} to {}", "a", "b"); // not a format string (mixing automatic and manual indexing),// ill-formed string s3 = format("{} to {1}", "a", "b"); // not a format string (mixing automatic and manual indexing),// ill-formed â *end example*]
[5](#general-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6012)
The *format-spec* field contains[*format specifications*](#def:format_specification,format_string "28.5.2.1 General [format.string.general]") that define how the value should be presented[.](#general-5.sentence-1)
Each type can define its own
interpretation of the *format-spec* field[.](#general-5.sentence-2)
If *format-spec* does not conform
to the format specifications for
the argument type referred to by *arg-id*,
the string is not a format string for args[.](#general-5.sentence-3)
[*Example [3](#general-example-3)*:
- [(5.1)](#general-5.1)
For arithmetic, pointer, and string types
the *format-spec* is interpreted as a *std-format-spec* as described in [[format.string.std]](#std "28.5.2.2 Standard format specifiers")[.](#general-5.1.sentence-1)
- [(5.2)](#general-5.2)
For chrono types
the *format-spec* is interpreted as a *chrono-format-spec* as described in [[time.format]](time.format "30.12 Formatting")[.](#general-5.2.sentence-1)
- [(5.3)](#general-5.3)
For user-defined formatter specializations,
the behavior of the parse member function
determines how the *format-spec* is interpreted[.](#general-5.3.sentence-1)
â *end example*]
#### [28.5.2.2](#std) Standard format specifiers [[format.string.std]](format.string.std)
[1](#std-1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6044)
Each formatter specialization
described in [[format.formatter.spec]](format.formatter.spec "28.5.6.4 Formatter specializations") for fundamental and string types
interprets *format-spec* as a*std-format-spec*[.](#std-1.sentence-1)
[*Note [1](#std-note-1)*:
The format specification can be used to specify such details as
minimum field width, alignment, padding, and decimal precision[.](#std-1.sentence-2)
Some of the formatting options
are only supported for arithmetic types[.](#std-1.sentence-3)
â *end note*]
The syntax of format specifications is as follows:
std-format-spec :
fill-and-alignopt [*sign*](lex.fcon#nt:sign "5.13.4 Floating-point literals [lex.fcon]")opt #opt 0opt widthopt precisionopt Lopt typeopt
fill-and-align :
fillopt align
fill :
any character other than { or }
align : one of
< > ^
[*sign*](lex.fcon#nt:sign "5.13.4 Floating-point literals [lex.fcon]") : one of
+ - space
width :
positive-integer
{ arg-idopt }
precision :
. nonnegative-integer
. { arg-idopt }
type : one of
a A b B c d e E f F g G o p P s x X ?
[2](#std-2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6100)
Field widths are specified in [*field width units*](#def:units,field_width "28.5.2.2 Standard format specifiers [format.string.std]");
the number of column positions required to display a sequence of
characters in a terminal[.](#std-2.sentence-1)
The [*minimum field width*](#def:field_width,minimum "28.5.2.2 Standard format specifiers [format.string.std]") is the number of field width units a replacement field minimally requires of
the formatted sequence of characters produced for a format argument[.](#std-2.sentence-2)
The [*estimated field width*](#def:field_width,estimated "28.5.2.2 Standard format specifiers [format.string.std]") is the number of field width units
that are required for the formatted sequence of characters
produced for a format argument independent of
the effects of the *width* option[.](#std-2.sentence-3)
The [*padding width*](#def:width,padding "28.5.2.2 Standard format specifiers [format.string.std]") is the greater of 0 and
the difference of the minimum field width and the estimated field width[.](#std-2.sentence-4)
[*Note [2](#std-note-2)*:
The POSIX wcswidth function is an example of a function that,
given a string, returns the number of column positions required by
a terminal to display the string[.](#std-2.sentence-5)
â *end note*]
[3](#std-3)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6120)
The [*fill character*](#def:character,fill "28.5.2.2 Standard format specifiers [format.string.std]") is the character denoted by
the *fill* option or,
if the *fill* option is absent, the space character[.](#std-3.sentence-1)
For a format specification in UTF-8, UTF-16, or UTF-32,
the fill character corresponds to a single Unicode scalar value[.](#std-3.sentence-2)
[*Note [3](#std-note-3)*:
The presence of a *fill* option
is signaled by the character following it,
which must be one of the alignment options[.](#std-3.sentence-3)
If the second character of *std-format-spec* is not a valid alignment option,
then it is assumed that
the *fill* and *align* options
are both absent[.](#std-3.sentence-4)
â *end note*]
[4](#std-4)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6137)
The *align* option applies to all argument types[.](#std-4.sentence-1)
The meaning of the various alignment options is as specified in Table [104](#tab:format.align "Table 104: Meaning of align options")[.](#std-4.sentence-2)
[*Example [1](#std-example-1)*: char c = 120;
string s0 = format("{:6}", 42); // value of s0 is " 42" string s1 = format("{:6}", 'x'); // value of s1 is "x " string s2 = format("{:*<6}", 'x'); // value of s2 is "x*****" string s3 = format("{:*>6}", 'x'); // value of s3 is "*****x" string s4 = format("{:*^6}", 'x'); // value of s4 is "**x***" string s5 = format("{:6d}", c); // value of s5 is " 120" string s6 = format("{:6}", true); // value of s6 is "true " string s7 = format("{:*<6.3}", "123456"); // value of s7 is "123***" string s8 = format("{:02}", 1234); // value of s8 is "1234" string s9 = format("{:*<}", "12"); // value of s9 is "12" string sA = format("{:*<6}", "12345678"); // value of sA is "12345678" string sB = format("{:ð¤¡^6}", "x"); // value of sB is "ð¤¡ð¤¡xð¤¡ð¤¡ð¤¡" string sC = format("{:*^6}", "ð¤¡ð¤¡ð¤¡"); // value of sC is "ð¤¡ð¤¡ð¤¡" â *end example*]
[*Note [4](#std-note-4)*:
The *fill*, *align*, and 0 options
have no effect when the minimum field width
is not greater than the estimated field width
because padding width is 0 in that case[.](#std-4.sentence-3)
Since fill characters are assumed to have a field width of 1,
use of a character with a different field width can produce misaligned output[.](#std-4.sentence-4)
The 𤡠(U+1f921 clown face) character has a field width of 2[.](#std-4.sentence-5)
The examples above that include that character
illustrate the effect of the field width
when that character is used as a fill character
as opposed to when it is used as a formatting argument[.](#std-4.sentence-6)
â *end note*]
Table [104](#tab:format.align) — Meaning of *align* options [[tab:format.align]](./tab:format.align)
| [ð](#tab:format.align-row-1)
**Option** | **Meaning** |
| --- | --- |
| [ð](#tab:format.align-row-2)
< | Forces the formatted argument to be aligned to the start of the field by inserting n fill characters after the formatted argument where n is the padding width[.](#tab:format.align-row-2-column-2-sentence-1)
This is the default for non-arithmetic non-pointer types, charT, and bool, unless an integer presentation type is specified[.](#tab:format.align-row-2-column-2-sentence-2) |
| [ð](#tab:format.align-row-3)
> | Forces the formatted argument to be aligned to the end of the field by inserting n fill characters before the formatted argument where n is the padding width[.](#tab:format.align-row-3-column-2-sentence-1)
This is the default for arithmetic types other than charT and bool, pointer types, or when an integer presentation type is specified[.](#tab:format.align-row-3-column-2-sentence-2) |
| [ð](#tab:format.align-row-4)
^ | Forces the formatted argument to be centered within the field by inserting ân2â fill characters before and ân2â fill characters after the formatted argument, where n is the padding width[.](#tab:format.align-row-4-column-2-sentence-1) |
[5](#std-5)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6205)
The *sign* option is only valid
for arithmetic types other than charT and bool or when an integer presentation type is specified[.](#std-5.sentence-1)
The meaning of the various options is as specified in Table [105](#tab:format.sign "Table 105: Meaning of sign options")[.](#std-5.sentence-2)
Table [105](#tab:format.sign) — Meaning of *sign* options [[tab:format.sign]](./tab:format.sign)
| [ð](#tab:format.sign-row-1)
**Option** | **Meaning** |
| --- | --- |
| [ð](#tab:format.sign-row-2)
+ | Indicates that a sign should be used for both non-negative and negative numbers[.](#tab:format.sign-row-2-column-2-sentence-1)
The + sign is inserted before the output of to_chars for non-negative numbers other than negative zero[.](#tab:format.sign-row-2-column-2-sentence-2)
[*Note [5](#tab:format.sign-row-2-column-2-note-5)*:
For negative numbers and negative zero the output of to_chars will already contain the sign so no additional transformation is performed[.](#tab:format.sign-row-2-column-2-sentence-3) â *end note*] |
| [ð](#tab:format.sign-row-3)
- | Indicates that a sign should be used for negative numbers and negative zero only (this is the default behavior)[.](#tab:format.sign-row-3-column-2-sentence-1) |
| [ð](#tab:format.sign-row-4)
space | Indicates that a leading space should be used for non-negative numbers other than negative zero, and a minus sign for negative numbers and negative zero[.](#tab:format.sign-row-4-column-2-sentence-1) |
[6](#std-6)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6238)
The *sign* option applies to floating-point infinity and NaN.
[*Example [2](#std-example-2)*: double inf = numeric_limits::infinity();double nan = numeric_limits::quiet_NaN();
string s0 = format("{0:},{0:+},{0:-},{0: }", 1); // value of s0 is "1,+1,1, 1" string s1 = format("{0:},{0:+},{0:-},{0: }", -1); // value of s1 is "-1,-1,-1,-1" string s2 = format("{0:},{0:+},{0:-},{0: }", inf); // value of s2 is "inf,+inf,inf, inf" string s3 = format("{0:},{0:+},{0:-},{0: }", nan); // value of s3 is "nan,+nan,nan, nan" â *end example*]
[7](#std-7)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6251)
The # option causes the[*alternate form*](#def:alternate_form,format_string "28.5.2.2 Standard format specifiers [format.string.std]") to be used for the conversion[.](#std-7.sentence-1)
This option is valid for arithmetic types other thancharT and bool or when an integer presentation type is specified, and not otherwise[.](#std-7.sentence-2)
For integral types,
the alternate form inserts the
base prefix (if any) specified in Table [107](#tab:format.type.int "Table 107: Meaning of type options for integer types") into the output after the sign character (possibly space) if there is one, or
before the output of to_chars otherwise[.](#std-7.sentence-3)
For floating-point types,
the alternate form causes the result of the conversion of finite values
to always contain a decimal-point character,
even if no digits follow it[.](#std-7.sentence-4)
Normally, a decimal-point character appears in the result of these
conversions only if a digit follows it[.](#std-7.sentence-5)
In addition, for g and G conversions,
trailing zeros are not removed from the result[.](#std-7.sentence-6)
[8](#std-8)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6276)
The 0 option is valid for arithmetic types
other than charT and bool, pointer types, or
when an integer presentation type is specified[.](#std-8.sentence-1)
For formatting arguments that have a value
other than an infinity or a NaN,
this option pads the formatted argument by
inserting the 0 character n times
following the sign or base prefix indicators (if any)
where n is 0 if the *align* option is present and
is the padding width otherwise[.](#std-8.sentence-2)
[*Example [3](#std-example-3)*: char c = 120;
string s1 = format("{:+06d}", c); // value of s1 is "+00120" string s2 = format("{:#06x}", 0xa); // value of s2 is "0x000a" string s3 = format("{:<06}", -42); // value of s3 is "-42 " (0 has no effect) string s4 = format("{:06}", inf); // value of s4 is " inf" (0 has no effect) â *end example*]
[9](#std-9)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6297)
The *width* option specifies the minimum field width[.](#std-9.sentence-1)
If the *width* option is absent,
the minimum field width is 0[.](#std-9.sentence-2)
[10](#std-10)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6302)
If { *arg-id*opt } is used in
a *width* or *precision* option,
the value of the corresponding formatting argument is used as the value of the option[.](#std-10.sentence-1)
The option is valid only if the corresponding formatting argument is
of standard signed or unsigned integer type[.](#std-10.sentence-2)
If its value is negative,
an exception of type format_error is thrown[.](#std-10.sentence-3)
[11](#std-11)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6311)
If *positive-integer* is used in a*width* option, the value of the *positive-integer* is interpreted as a decimal integer and used as the value of the option[.](#std-11.sentence-1)
[12](#std-12)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6317)
For the purposes of width computation,
a string is assumed to be in
a locale-independent,implementation-defined encoding[.](#std-12.sentence-1)
Implementations should use either UTF-8, UTF-16, or UTF-32,
on platforms capable of displaying Unicode text in a terminal[.](#std-12.sentence-2)
[*Note [6](#std-note-6)*:
This is the case for Windows®-based[237](#footnote-237 "Windows® is a registered trademark of Microsoft Corporation. This information is given for the convenience of users of this document and does not constitute an endorsement by ISO or IEC of this product.") and many POSIX-based operating systems[.](#std-12.sentence-3)
â *end note*]
[13](#std-13)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6334)
For a sequence of characters in UTF-8, UTF-16, or UTF-32,
an implementation should use as its field width
the sum of the field widths of the first code point
of each extended grapheme cluster[.](#std-13.sentence-1)
Extended grapheme clusters are defined by UAX #29 of the Unicode Standard[.](#std-13.sentence-2)
The following code points have a field width of 2:
- [(13.1)](#std-13.1)
any code point with the East_Asian_Width="W" orEast_Asian_Width="F" property as described by
UAX #44 of the Unicode Standard
- [(13.2)](#std-13.2)
U+4dc0 â U+4dff (Yijing Hexagram Symbols)
- [(13.3)](#std-13.3)
U+1f300 â U+1f5ff (Miscellaneous Symbols and Pictographs)
- [(13.4)](#std-13.4)
U+1f900 â U+1f9ff (Supplemental Symbols and Pictographs)
The field width of all other code points is 1[.](#std-13.sentence-3)
[14](#std-14)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6355)
For a sequence of characters in neither UTF-8, UTF-16, nor UTF-32,
the field width is unspecified[.](#std-14.sentence-1)
[15](#std-15)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6359)
The *precision* option is valid
for floating-point and string types[.](#std-15.sentence-1)
For floating-point types,
the value of this option specifies the precision
to be used for the floating-point presentation type[.](#std-15.sentence-2)
For string types,
this option specifies the longest prefix of the formatted argument
to be included in the replacement field such that
the field width of the prefix is no greater than the value of this option[.](#std-15.sentence-3)
[16](#std-16)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6370)
If *nonnegative-integer* is used in
a *precision* option,
the value of the decimal integer is used as the value of the option[.](#std-16.sentence-1)
[17](#std-17)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6375)
When the L option is used, the form used for the conversion is called
the [*locale-specific form*](#def:locale-specific_form,format_string "28.5.2.2 Standard format specifiers [format.string.std]")[.](#std-17.sentence-1)
The L option is only valid for arithmetic types, and
its effect depends upon the type[.](#std-17.sentence-2)
- [(17.1)](#std-17.1)
For integral types, the locale-specific form
causes the context's locale to be used
to insert the appropriate digit group separator characters[.](#std-17.1.sentence-1)
- [(17.2)](#std-17.2)
For floating-point types, the locale-specific form
causes the context's locale to be used
to insert the appropriate digit group and radix separator characters[.](#std-17.2.sentence-1)
- [(17.3)](#std-17.3)
For the textual representation of bool, the locale-specific form
causes the context's locale to be used
to insert the appropriate string as if obtained
with numpunct::truename or numpunct::falsename[.](#std-17.3.sentence-1)
[18](#std-18)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6398)
The *type* determines how the data should be presented[.](#std-18.sentence-1)
[19](#std-19)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6401)
The available string presentation types are specified in Table [106](#tab:format.type.string "Table 106: Meaning of type options for strings")[.](#std-19.sentence-1)
Table [106](#tab:format.type.string) — Meaning of *type* options for strings [[tab:format.type.string]](./tab:format.type.string)
| [ð](#tab:format.type.string-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.string-row-2)
none, s | Copies the string to the output[.](#tab:format.type.string-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.string-row-3)
? | Copies the escaped string ([[format.string.escaped]](format.string.escaped "28.5.6.5 Formatting escaped characters and strings")) to the output[.](#tab:format.type.string-row-3-column-2-sentence-1) |
[20](#std-20)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6417)
The meaning of some non-string presentation types
is defined in terms of a call to to_chars[.](#std-20.sentence-1)
In such cases,
let [first, last) be a range
large enough to hold the to_chars output
and value be the formatting argument value[.](#std-20.sentence-2)
Formatting is done as if by calling to_chars as specified
and copying the output through the output iterator of the format context[.](#std-20.sentence-3)
[*Note [7](#std-note-7)*:
Additional padding and adjustments are performed
prior to copying the output through the output iterator
as specified by the format specifiers[.](#std-20.sentence-4)
â *end note*]
[21](#std-21)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6432)
The available integer presentation types
for integral types other than bool and charT are specified in Table [107](#tab:format.type.int "Table 107: Meaning of type options for integer types")[.](#std-21.sentence-1)
[*Example [4](#std-example-4)*: string s0 = format("{}", 42); // value of s0 is "42" string s1 = format("{0:b} {0:d} {0:o} {0:x}", 42); // value of s1 is "101010 42 52 2a" string s2 = format("{0:#x} {0:#X}", 42); // value of s2 is "0x2a 0X2A" string s3 = format("{:L}", 1234); // value of s3 can be "1,234"// (depending on the locale) â *end example*]
Table [107](#tab:format.type.int) — Meaning of *type* options for integer types [[tab:format.type.int]](./tab:format.type.int)
| [ð](#tab:format.type.int-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.int-row-2)
b | to_chars(first, last, value, 2); the base prefix is 0b[.](#tab:format.type.int-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-3)
B | The same as b, except that the base prefix is 0B[.](#tab:format.type.int-row-3-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-4)
c | Copies the character static_cast(value) to the output[.](#tab:format.type.int-row-4-column-2-sentence-1)
Throws format_error if value is not in the range of representable values for charT[.](#tab:format.type.int-row-4-column-2-sentence-2) |
| [ð](#tab:format.type.int-row-5)
d | to_chars(first, last, value)[.](#tab:format.type.int-row-5-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-6)
o | to_chars(first, last, value, 8); the base prefix is 0 if value is nonzero and is empty otherwise[.](#tab:format.type.int-row-6-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-7)
x | to_chars(first, last, value, 16); the base prefix is 0x[.](#tab:format.type.int-row-7-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-8)
X | The same as x, except that it uses uppercase letters for digits above 9 and the base prefix is 0X[.](#tab:format.type.int-row-8-column-2-sentence-1) |
| [ð](#tab:format.type.int-row-9)
none | The same as d[.](#tab:format.type.int-row-9-column-2-sentence-1)
[*Note [8](#tab:format.type.int-row-9-column-2-note-8)*:
If the formatting argument type is charT or bool, the default is instead c or s, respectively[.](#tab:format.type.int-row-9-column-2-sentence-2) â *end note*] |
[22](#std-22)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6499)
The available charT presentation types are specified in Table [108](#tab:format.type.char "Table 108: Meaning of type options for charT")[.](#std-22.sentence-1)
Table [108](#tab:format.type.char) — Meaning of *type* options for charT [[tab:format.type.char]](./tab:format.type.char)
| [ð](#tab:format.type.char-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.char-row-2)
none, c | Copies the character to the output[.](#tab:format.type.char-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.char-row-3)
b, B, d, o, x, X | As specified in Table [107](#tab:format.type.int "Table 107: Meaning of type options for integer types") with value converted to the unsigned version of the underlying type[.](#tab:format.type.char-row-3-column-2-sentence-1) |
| [ð](#tab:format.type.char-row-4)
? | Copies the escaped character ([[format.string.escaped]](format.string.escaped "28.5.6.5 Formatting escaped characters and strings")) to the output[.](#tab:format.type.char-row-4-column-2-sentence-1) |
[23](#std-23)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6519)
The available bool presentation types are specified in Table [109](#tab:format.type.bool "Table 109: Meaning of type options for bool")[.](#std-23.sentence-1)
Table [109](#tab:format.type.bool) — Meaning of *type* options for bool [[tab:format.type.bool]](./tab:format.type.bool)
| [ð](#tab:format.type.bool-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.bool-row-2)
none, s | Copies textual representation, either true or false, to the output[.](#tab:format.type.bool-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.bool-row-3)
b, B, d, o, x, X | As specified in Table [107](#tab:format.type.int "Table 107: Meaning of type options for integer types") for the value static_cast(value)[.](#tab:format.type.bool-row-3-column-2-sentence-1) |
[24](#std-24)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6537)
The available floating-point presentation types and their meanings
for values other than infinity and NaN are
specified in Table [110](#tab:format.type.float "Table 110: Meaning of type options for floating-point types")[.](#std-24.sentence-1)
For lower-case presentation types, infinity and NaN are formatted asinf and nan, respectively[.](#std-24.sentence-2)
For upper-case presentation types, infinity and NaN are formatted asINF and NAN, respectively[.](#std-24.sentence-3)
[*Note [9](#std-note-9)*:
In either case, a sign is included
if indicated by the *sign* option[.](#std-24.sentence-4)
â *end note*]
Table [110](#tab:format.type.float) — Meaning of *type* options for floating-point types [[tab:format.type.float]](./tab:format.type.float)
| [ð](#tab:format.type.float-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.float-row-2)
a | If *precision* is specified, equivalent to to_chars(first, last, value, chars_format::hex, precision) where precision is the specified formatting precision; equivalent to to_chars(first, last, value, chars_format::hex) otherwise[.](#tab:format.type.float-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-3)
A | The same as a, except that it uses uppercase letters for digits above 9 and P to indicate the exponent[.](#tab:format.type.float-row-3-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-4)
e | Equivalent to to_chars(first, last, value, chars_format::scientific, precision) where precision is the specified formatting precision, or 6 if *precision* is not specified[.](#tab:format.type.float-row-4-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-5)
E | The same as e, except that it uses E to indicate exponent[.](#tab:format.type.float-row-5-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-6)
f, F | Equivalent to to_chars(first, last, value, chars_format::fixed, precision) where precision is the specified formatting precision, or 6 if *precision* is not specified[.](#tab:format.type.float-row-6-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-7)
g | Equivalent to to_chars(first, last, value, chars_format::general, precision) where precision is the specified formatting precision, or 6 if *precision* is not specified[.](#tab:format.type.float-row-7-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-8)
G | The same as g, except that it uses E to indicate exponent[.](#tab:format.type.float-row-8-column-2-sentence-1) |
| [ð](#tab:format.type.float-row-9)
none | If *precision* is specified, equivalent to to_chars(first, last, value, chars_format::general, precision) where precision is the specified formatting precision; equivalent to to_chars(first, last, value) otherwise[.](#tab:format.type.float-row-9-column-2-sentence-1) |
[25](#std-25)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L6621)
The available pointer presentation types and their mapping toto_chars are specified in Table [111](#tab:format.type.ptr "Table 111: Meaning of type options for pointer types")[.](#std-25.sentence-1)
[*Note [10](#std-note-10)*:
Pointer presentation types also apply to nullptr_t[.](#std-25.sentence-2)
â *end note*]
Table [111](#tab:format.type.ptr) — Meaning of *type* options for pointer types [[tab:format.type.ptr]](./tab:format.type.ptr)
| [ð](#tab:format.type.ptr-row-1)
**Type** | **Meaning** |
| --- | --- |
| [ð](#tab:format.type.ptr-row-2)
none, p | If uintptr_t is defined, to_chars(first, last, reinterpret_cast(value), 16) with the prefix 0x inserted immediately before the output of to_chars; otherwise, implementation-defined[.](#tab:format.type.ptr-row-2-column-2-sentence-1) |
| [ð](#tab:format.type.ptr-row-3)
P | The same as p, except that it uses uppercase letters for digits above 9 and the base prefix is 0X[.](#tab:format.type.ptr-row-3-column-2-sentence-1) |
[237)](#footnote-237)[237)](#footnoteref-237)
Windows® is a registered trademark of Microsoft Corporation[.](#footnote-237.sentence-1)
This information is given for the convenience of users of this document and
does not constitute an endorsement by ISO or IEC of this product[.](#footnote-237.sentence-2)