tmp/tmpo1tofvmw/{from.md → to.md}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
### Format string <a id="format.string">[[format.string]]</a>
|
| 2 |
|
| 3 |
-
####
|
| 4 |
|
| 5 |
A *format string* for arguments `args` is a (possibly empty) sequence of
|
| 6 |
*replacement fields*, *escape sequences*, and characters other than `{`
|
| 7 |
and `}`. Let `charT` be the character type of the format string. Each
|
| 8 |
character that is not part of a replacement field or an escape sequence
|
|
@@ -48,11 +48,11 @@ format-specifier
|
|
| 48 |
':' format-spec
|
| 49 |
```
|
| 50 |
|
| 51 |
``` bnf
|
| 52 |
format-spec
|
| 53 |
-
as specified by the formatter specialization for the argument type
|
| 54 |
```
|
| 55 |
|
| 56 |
The *arg-id* field specifies the index of the argument in `args` whose
|
| 57 |
value is to be formatted and inserted into the output instead of the
|
| 58 |
replacement field. If there is no argument with the index *arg-id* in
|
|
@@ -97,14 +97,14 @@ conform to the format specifications for the argument type referred to
|
|
| 97 |
by *arg-id*, the string is not a format string for `args`.
|
| 98 |
|
| 99 |
[*Example 3*:
|
| 100 |
|
| 101 |
- For arithmetic, pointer, and string types the *format-spec* is
|
| 102 |
-
interpreted as a *std-format-spec* as described in
|
| 103 |
[[format.string.std]].
|
| 104 |
- For chrono types the *format-spec* is interpreted as a
|
| 105 |
-
*chrono-format-spec* as described in
|
| 106 |
- For user-defined `formatter` specializations, the behavior of the
|
| 107 |
`parse` member function determines how the *format-spec* is
|
| 108 |
interpreted.
|
| 109 |
|
| 110 |
— *end example*]
|
|
@@ -159,11 +159,11 @@ precision
|
|
| 159 |
'.' '{' arg-idₒₚₜ '}'
|
| 160 |
```
|
| 161 |
|
| 162 |
``` bnf
|
| 163 |
type one of
|
| 164 |
-
'a A b B c d e E f F g G o p s x X ?'
|
| 165 |
```
|
| 166 |
|
| 167 |
Field widths are specified in *field width units*; the number of column
|
| 168 |
positions required to display a sequence of characters in a terminal.
|
| 169 |
The *minimum field width* is the number of field width units a
|
|
@@ -206,20 +206,22 @@ string s5 = format("{:6d}", c); // value of s5 is "\ \ \ 120"
|
|
| 206 |
string s6 = format("{:6}", true); // value of s6 is "true\ \ "
|
| 207 |
string s7 = format("{:*<6.3}", "123456"); // value of s7 is "123***"
|
| 208 |
string s8 = format("{:02}", 1234); // value of s8 is "1234"
|
| 209 |
string s9 = format("{:*<}", "12"); // value of s9 is "12"
|
| 210 |
string sA = format("{:*<6}", "12345678"); // value of sA is "12345678"
|
|
|
|
|
|
|
| 211 |
```
|
| 212 |
|
| 213 |
— *end example*]
|
| 214 |
|
| 215 |
[*Note 4*: The *fill*, *align*, and `0` options have no effect when the
|
| 216 |
minimum field width is not greater than the estimated field width
|
| 217 |
because padding width is `0` in that case. Since fill characters are
|
| 218 |
assumed to have a field width of `1`, use of a character with a
|
| 219 |
different field width can produce misaligned output. The
|
| 220 |
-
U+1f921 (clown face) character has a field width of `2`. The examples
|
| 221 |
above that include that character illustrate the effect of the field
|
| 222 |
width when that character is used as a fill character as opposed to when
|
| 223 |
it is used as a formatting argument. — *end note*]
|
| 224 |
|
| 225 |
**Table: Meaning of align options** <a id="format.align">[format.align]</a>
|
|
@@ -271,15 +273,16 @@ contain a decimal-point character, even if no digits follow it.
|
|
| 271 |
Normally, a decimal-point character appears in the result of these
|
| 272 |
conversions only if a digit follows it. In addition, for `g` and `G`
|
| 273 |
conversions, trailing zeros are not removed from the result.
|
| 274 |
|
| 275 |
The `0` option is valid for arithmetic types other than `charT` and
|
| 276 |
-
`bool` or when an integer presentation type is
|
| 277 |
-
arguments that have a value other than an
|
| 278 |
-
|
| 279 |
-
following the sign or base prefix indicators
|
| 280 |
-
the *align* option is present and is the
|
|
|
|
| 281 |
|
| 282 |
[*Example 3*:
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
char c = 120;
|
|
@@ -294,13 +297,13 @@ string s4 = format("{:06}", inf); // value of s4 is "\ \ \ inf" (0 has no
|
|
| 294 |
The *width* option specifies the minimum field width. If the *width*
|
| 295 |
option is absent, the minimum field width is `0`.
|
| 296 |
|
| 297 |
If `{ \opt{arg-id} }` is used in a *width* or *precision* option, the
|
| 298 |
value of the corresponding formatting argument is used as the value of
|
| 299 |
-
the option.
|
| 300 |
-
signed or unsigned integer type
|
| 301 |
-
of type `format_error` is thrown.
|
| 302 |
|
| 303 |
If *positive-integer* is used in a *width* option, the value of the
|
| 304 |
*positive-integer* is interpreted as a decimal integer and used as the
|
| 305 |
value of the option.
|
| 306 |
|
|
@@ -309,25 +312,25 @@ locale-independent, *implementation-defined* encoding. Implementations
|
|
| 309 |
should use either UTF-8, UTF-16, or UTF-32, on platforms capable of
|
| 310 |
displaying Unicode text in a terminal.
|
| 311 |
|
| 312 |
[*Note 5*:
|
| 313 |
|
| 314 |
-
This is the case for Windows[^
|
| 315 |
|
| 316 |
-
|
| 317 |
|
| 318 |
— *end note*]
|
| 319 |
|
| 320 |
For a sequence of characters in UTF-8, UTF-16, or UTF-32, an
|
| 321 |
implementation should use as its field width the sum of the field widths
|
| 322 |
of the first code point of each extended grapheme cluster. Extended
|
| 323 |
grapheme clusters are defined by UAX \#29 of the Unicode Standard. The
|
| 324 |
following code points have a field width of 2:
|
| 325 |
|
| 326 |
- any code point with the `East_Asian_Width="W"` or
|
| 327 |
-
`East_Asian_Width="F"`
|
| 328 |
-
|
| 329 |
- `U+4dc0` – `U+4dff` (Yijing Hexagram Symbols)
|
| 330 |
- `U+1f300` – `U+1f5ff` (Miscellaneous Symbols and Pictographs)
|
| 331 |
- `U+1f900` – `U+1f9ff` (Supplemental Symbols and Pictographs)
|
| 332 |
|
| 333 |
The field width of all other code points is 1.
|
|
@@ -417,13 +420,13 @@ The available `charT` presentation types are specified in
|
|
| 417 |
[[format.type.char]].
|
| 418 |
|
| 419 |
**Table: Meaning of type options for `charT`** <a id="format.type.char">[format.type.char]</a>
|
| 420 |
|
| 421 |
| Type | Meaning |
|
| 422 |
-
| ------------------------------ | --------------------------------------------------------------------- |
|
| 423 |
| none, `c` | Copies the character to the output. |
|
| 424 |
-
| % `b`, `B`, `d`, `o`, `x`, `X` | As specified in [[format.type.int]].
|
| 425 |
| % `?` | Copies the escaped character [[format.string.escaped]] to the output. |
|
| 426 |
|
| 427 |
|
| 428 |
The available `bool` presentation types are specified in
|
| 429 |
[[format.type.bool]].
|
|
@@ -469,7 +472,8 @@ are specified in [[format.type.ptr]].
|
|
| 469 |
**Table: Meaning of type options for pointer types** <a id="format.type.ptr">[format.type.ptr]</a>
|
| 470 |
|
| 471 |
| Type | Meaning |
|
| 472 |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 473 |
| none, `p` | If `uintptr_t` is defined, \begin{codeblock} to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16) \end{codeblock} with the prefix `0x` inserted immediately before the output of `to_chars`; otherwise, implementation-defined. |
|
|
|
|
| 474 |
|
| 475 |
|
|
|
|
| 1 |
### Format string <a id="format.string">[[format.string]]</a>
|
| 2 |
|
| 3 |
+
#### General <a id="format.string.general">[[format.string.general]]</a>
|
| 4 |
|
| 5 |
A *format string* for arguments `args` is a (possibly empty) sequence of
|
| 6 |
*replacement fields*, *escape sequences*, and characters other than `{`
|
| 7 |
and `}`. Let `charT` be the character type of the format string. Each
|
| 8 |
character that is not part of a replacement field or an escape sequence
|
|
|
|
| 48 |
':' format-spec
|
| 49 |
```
|
| 50 |
|
| 51 |
``` bnf
|
| 52 |
format-spec
|
| 53 |
+
as specified by the formatter specialization for the argument type; cannot start with '}'
|
| 54 |
```
|
| 55 |
|
| 56 |
The *arg-id* field specifies the index of the argument in `args` whose
|
| 57 |
value is to be formatted and inserted into the output instead of the
|
| 58 |
replacement field. If there is no argument with the index *arg-id* in
|
|
|
|
| 97 |
by *arg-id*, the string is not a format string for `args`.
|
| 98 |
|
| 99 |
[*Example 3*:
|
| 100 |
|
| 101 |
- For arithmetic, pointer, and string types the *format-spec* is
|
| 102 |
+
interpreted as a *std-format-spec* as described in
|
| 103 |
[[format.string.std]].
|
| 104 |
- For chrono types the *format-spec* is interpreted as a
|
| 105 |
+
*chrono-format-spec* as described in [[time.format]].
|
| 106 |
- For user-defined `formatter` specializations, the behavior of the
|
| 107 |
`parse` member function determines how the *format-spec* is
|
| 108 |
interpreted.
|
| 109 |
|
| 110 |
— *end example*]
|
|
|
|
| 159 |
'.' '{' arg-idₒₚₜ '}'
|
| 160 |
```
|
| 161 |
|
| 162 |
``` bnf
|
| 163 |
type one of
|
| 164 |
+
'a A b B c d e E f F g G o p P s x X ?'
|
| 165 |
```
|
| 166 |
|
| 167 |
Field widths are specified in *field width units*; the number of column
|
| 168 |
positions required to display a sequence of characters in a terminal.
|
| 169 |
The *minimum field width* is the number of field width units a
|
|
|
|
| 206 |
string s6 = format("{:6}", true); // value of s6 is "true\ \ "
|
| 207 |
string s7 = format("{:*<6.3}", "123456"); // value of s7 is "123***"
|
| 208 |
string s8 = format("{:02}", 1234); // value of s8 is "1234"
|
| 209 |
string s9 = format("{:*<}", "12"); // value of s9 is "12"
|
| 210 |
string sA = format("{:*<6}", "12345678"); // value of sA is "12345678"
|
| 211 |
+
string sB = format("{:\importexample[-2pt]{example_05}\kern0.75pt^6}", "x"); // value of sB is "\importexample[-2pt]{example_05\importexample[-2pt]{example_05}x\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
|
| 212 |
+
string sC = format("{:*^6}", "\importexample[-2pt]{example_05}\kern0.75pt\importexample[-2pt]{example_05}\kern0.75pt\importexample[-2pt]{example_05}\kern0.75pt"); // value of sC is "\importexample[-2pt]{example_05\importexample[-2pt]{example_05}\importexample[-2pt]{example_05}"}
|
| 213 |
```
|
| 214 |
|
| 215 |
— *end example*]
|
| 216 |
|
| 217 |
[*Note 4*: The *fill*, *align*, and `0` options have no effect when the
|
| 218 |
minimum field width is not greater than the estimated field width
|
| 219 |
because padding width is `0` in that case. Since fill characters are
|
| 220 |
assumed to have a field width of `1`, use of a character with a
|
| 221 |
different field width can produce misaligned output. The
|
| 222 |
+
(U+1f921 (clown face)) character has a field width of `2`. The examples
|
| 223 |
above that include that character illustrate the effect of the field
|
| 224 |
width when that character is used as a fill character as opposed to when
|
| 225 |
it is used as a formatting argument. — *end note*]
|
| 226 |
|
| 227 |
**Table: Meaning of align options** <a id="format.align">[format.align]</a>
|
|
|
|
| 273 |
Normally, a decimal-point character appears in the result of these
|
| 274 |
conversions only if a digit follows it. In addition, for `g` and `G`
|
| 275 |
conversions, trailing zeros are not removed from the result.
|
| 276 |
|
| 277 |
The `0` option is valid for arithmetic types other than `charT` and
|
| 278 |
+
`bool`, pointer types, or when an integer presentation type is
|
| 279 |
+
specified. For formatting arguments that have a value other than an
|
| 280 |
+
infinity or a NaN, this option pads the formatted argument by inserting
|
| 281 |
+
the `0` character n times following the sign or base prefix indicators
|
| 282 |
+
(if any) where n is `0` if the *align* option is present and is the
|
| 283 |
+
padding width otherwise.
|
| 284 |
|
| 285 |
[*Example 3*:
|
| 286 |
|
| 287 |
``` cpp
|
| 288 |
char c = 120;
|
|
|
|
| 297 |
The *width* option specifies the minimum field width. If the *width*
|
| 298 |
option is absent, the minimum field width is `0`.
|
| 299 |
|
| 300 |
If `{ \opt{arg-id} }` is used in a *width* or *precision* option, the
|
| 301 |
value of the corresponding formatting argument is used as the value of
|
| 302 |
+
the option. The option is valid only if the corresponding formatting
|
| 303 |
+
argument is of standard signed or unsigned integer type. If its value is
|
| 304 |
+
negative, an exception of type `format_error` is thrown.
|
| 305 |
|
| 306 |
If *positive-integer* is used in a *width* option, the value of the
|
| 307 |
*positive-integer* is interpreted as a decimal integer and used as the
|
| 308 |
value of the option.
|
| 309 |
|
|
|
|
| 312 |
should use either UTF-8, UTF-16, or UTF-32, on platforms capable of
|
| 313 |
displaying Unicode text in a terminal.
|
| 314 |
|
| 315 |
[*Note 5*:
|
| 316 |
|
| 317 |
+
This is the case for Windows®-based[^25]
|
| 318 |
|
| 319 |
+
and many POSIX-based operating systems.
|
| 320 |
|
| 321 |
— *end note*]
|
| 322 |
|
| 323 |
For a sequence of characters in UTF-8, UTF-16, or UTF-32, an
|
| 324 |
implementation should use as its field width the sum of the field widths
|
| 325 |
of the first code point of each extended grapheme cluster. Extended
|
| 326 |
grapheme clusters are defined by UAX \#29 of the Unicode Standard. The
|
| 327 |
following code points have a field width of 2:
|
| 328 |
|
| 329 |
- any code point with the `East_Asian_Width="W"` or
|
| 330 |
+
`East_Asian_Width="F"` property as described by UAX \#44 of the
|
| 331 |
+
Unicode Standard
|
| 332 |
- `U+4dc0` – `U+4dff` (Yijing Hexagram Symbols)
|
| 333 |
- `U+1f300` – `U+1f5ff` (Miscellaneous Symbols and Pictographs)
|
| 334 |
- `U+1f900` – `U+1f9ff` (Supplemental Symbols and Pictographs)
|
| 335 |
|
| 336 |
The field width of all other code points is 1.
|
|
|
|
| 420 |
[[format.type.char]].
|
| 421 |
|
| 422 |
**Table: Meaning of type options for `charT`** <a id="format.type.char">[format.type.char]</a>
|
| 423 |
|
| 424 |
| Type | Meaning |
|
| 425 |
+
| ------------------------------ | ---------------------------------------------------------------------------------------------------------- |
|
| 426 |
| none, `c` | Copies the character to the output. |
|
| 427 |
+
| % `b`, `B`, `d`, `o`, `x`, `X` | As specified in [[format.type.int]] with `value` converted to the unsigned version of the underlying type. |
|
| 428 |
| % `?` | Copies the escaped character [[format.string.escaped]] to the output. |
|
| 429 |
|
| 430 |
|
| 431 |
The available `bool` presentation types are specified in
|
| 432 |
[[format.type.bool]].
|
|
|
|
| 472 |
**Table: Meaning of type options for pointer types** <a id="format.type.ptr">[format.type.ptr]</a>
|
| 473 |
|
| 474 |
| Type | Meaning |
|
| 475 |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 476 |
| none, `p` | If `uintptr_t` is defined, \begin{codeblock} to_chars(first, last, reinterpret_cast<uintptr_t>(value), 16) \end{codeblock} with the prefix `0x` inserted immediately before the output of `to_chars`; otherwise, implementation-defined. |
|
| 477 |
+
| `P` | The same as `p`, except that it uses uppercase letters for digits above `9` and the base prefix is `0X`. |
|
| 478 |
|
| 479 |
|