tmp/tmpt7pfo0hf/{from.md → to.md}
RENAMED
|
@@ -5,19 +5,18 @@ parsing. Virtual functions are provided for several numeric types.
|
|
| 5 |
Implementations may (but are not required to) delegate extraction of
|
| 6 |
smaller types to extractors for larger types.[^11]
|
| 7 |
|
| 8 |
All specifications of member functions for `num_put` and `num_get` in
|
| 9 |
the subclauses of [[category.numeric]] only apply to the
|
| 10 |
-
specializations required in Tables [[tab:
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
`
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
`ctype<>` facet to perform character classification.
|
| 19 |
|
| 20 |
Extractor and inserter members of the standard iostreams use `num_get<>`
|
| 21 |
and `num_put<>` member functions for formatting and parsing numeric
|
| 22 |
values ([[istream.formatted.reqmts]], [[ostream.formatted.reqmts]]).
|
| 23 |
|
|
@@ -87,11 +86,11 @@ namespace std {
|
|
| 87 |
```
|
| 88 |
|
| 89 |
The facet `num_get` is used to parse numeric values from an input
|
| 90 |
sequence such as an istream.
|
| 91 |
|
| 92 |
-
#####
|
| 93 |
|
| 94 |
``` cpp
|
| 95 |
iter_type get(iter_type in, iter_type end, ios_base& str,
|
| 96 |
ios_base::iostate& err, bool& val) const;
|
| 97 |
iter_type get(iter_type in, iter_type end, ios_base& str,
|
|
@@ -116,11 +115,11 @@ iter_type get(iter_type in, iter_type end, ios_base& str,
|
|
| 116 |
ios_base::iostate& err, void*& val) const;
|
| 117 |
```
|
| 118 |
|
| 119 |
*Returns:* `do_get(in, end, str, err, val)`.
|
| 120 |
|
| 121 |
-
#####
|
| 122 |
|
| 123 |
``` cpp
|
| 124 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 125 |
ios_base::iostate& err, long& val) const;
|
| 126 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
|
@@ -167,32 +166,32 @@ fmtflags basefield = (flags & ios_base::basefield);
|
|
| 167 |
fmtflags uppercase = (flags & ios_base::uppercase);
|
| 168 |
fmtflags boolalpha = (flags & ios_base::boolalpha);
|
| 169 |
```
|
| 170 |
|
| 171 |
For conversion to an integral type, the function determines the integral
|
| 172 |
-
conversion specifier as indicated in
|
| 173 |
-
|
| 174 |
-
|
| 175 |
|
| 176 |
-
**Table: Integer conversions** <a id="
|
| 177 |
|
| 178 |
| State | `stdio` equivalent |
|
| 179 |
| ------------------------ | ------------------ |
|
| 180 |
| `basefield == oct` | `%o` |
|
| 181 |
| `basefield == hex` | `%X` |
|
| 182 |
| `basefield == 0` | `%i` `signed` integral type | `%d` |
|
| 183 |
| `unsigned` integral type | `%u` |
|
| 184 |
|
| 185 |
|
| 186 |
-
For conversions to a floating type the specifier is `%g`.
|
| 187 |
|
| 188 |
For conversions to `void*` the specifier is `%p`.
|
| 189 |
|
| 190 |
A length modifier is added to the conversion specification, if needed,
|
| 191 |
-
as indicated in
|
| 192 |
|
| 193 |
-
**Table: Length modifier** <a id="
|
| 194 |
|
| 195 |
| Type | Length modifier |
|
| 196 |
| -------------------- | --------------- |
|
| 197 |
| `short` | `h` |
|
| 198 |
| `unsigned short` | `h` |
|
|
@@ -360,11 +359,11 @@ namespace std {
|
|
| 360 |
```
|
| 361 |
|
| 362 |
The facet `num_put` is used to format numeric values to a character
|
| 363 |
sequence such as an ostream.
|
| 364 |
|
| 365 |
-
#####
|
| 366 |
|
| 367 |
``` cpp
|
| 368 |
iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
|
| 369 |
iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 370 |
iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
|
@@ -375,11 +374,11 @@ iter_type put(iter_type out, ios_base& str, char_type fill, long double val) con
|
|
| 375 |
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 376 |
```
|
| 377 |
|
| 378 |
*Returns:* `do_put(out, str, fill, val)`.
|
| 379 |
|
| 380 |
-
#####
|
| 381 |
|
| 382 |
``` cpp
|
| 383 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 384 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 385 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
|
@@ -388,30 +387,30 @@ iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const
|
|
| 388 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 389 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 390 |
```
|
| 391 |
|
| 392 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 393 |
-
desired. In the following description, a local variable
|
| 394 |
-
|
| 395 |
|
| 396 |
``` cpp
|
| 397 |
locale loc = str.getloc();
|
| 398 |
```
|
| 399 |
|
| 400 |
The details of this operation occur in several stages:
|
| 401 |
|
| 402 |
- Stage 1: Determine a printf conversion specifier `spec` and determine
|
| 403 |
-
the characters that would be printed by `printf`
|
| 404 |
this conversion specifier for
|
| 405 |
``` cpp
|
| 406 |
printf(spec, val)
|
| 407 |
```
|
| 408 |
|
| 409 |
assuming that the current locale is the `"C"` locale.
|
| 410 |
- Stage 2: Adjust the representation by converting each `char`
|
| 411 |
determined by stage 1 to a `charT` using a conversion and values
|
| 412 |
-
returned by members of `use_facet<numpunct<charT>>(
|
| 413 |
- Stage 3: Determine where padding is required.
|
| 414 |
- Stage 4: Insert the sequence into the `out`.
|
| 415 |
|
| 416 |
Detailed descriptions of each stage follow.
|
| 417 |
|
|
@@ -437,13 +436,13 @@ All tables used in describing stage 1 are ordered. That is, the first
|
|
| 437 |
line whose condition is true applies. A line without a condition is the
|
| 438 |
default behavior when none of the earlier lines apply.
|
| 439 |
|
| 440 |
For conversion from an integral type other than a character type, the
|
| 441 |
function determines the integral conversion specifier as indicated in
|
| 442 |
-
|
| 443 |
|
| 444 |
-
**Table: Integer conversions** <a id="
|
| 445 |
|
| 446 |
| State | `stdio` equivalent |
|
| 447 |
| -------------------------------------------- | ------------------ |
|
| 448 |
| `basefield == ios_base::oct` | `%o` |
|
| 449 |
| `(basefield == ios_base::hex) && !uppercase` | `%x` |
|
|
@@ -452,13 +451,13 @@ Table [[tab:localization.integer.conversions.out]].
|
|
| 452 |
| for an `unsigned` integral type | `%u` |
|
| 453 |
|
| 454 |
|
| 455 |
For conversion from a floating-point type, the function determines the
|
| 456 |
floating-point conversion specifier as indicated in
|
| 457 |
-
|
| 458 |
|
| 459 |
-
**Table: Floating-point conversions** <a id="
|
| 460 |
|
| 461 |
| State | `stdio` equivalent |
|
| 462 |
| ---------------------------------------------------------------------- | ------------------ |
|
| 463 |
| `floatfield == ios_base::fixed` | `%f` |
|
| 464 |
| `floatfield == ios_base::scientific && !uppercase` | `%e` |
|
|
@@ -469,13 +468,13 @@ Table [[tab:localization.fp.conversions.out]].
|
|
| 469 |
| otherwise | `%G` |
|
| 470 |
|
| 471 |
|
| 472 |
For conversions from an integral or floating-point type a length
|
| 473 |
modifier is added to the conversion specifier as indicated in
|
| 474 |
-
|
| 475 |
|
| 476 |
-
**Table: Length modifier** <a id="
|
| 477 |
|
| 478 |
| Type | Length modifier |
|
| 479 |
| -------------------- | --------------- |
|
| 480 |
| `long` | `l` |
|
| 481 |
| `long long` | `ll` |
|
|
@@ -484,14 +483,13 @@ Table [[tab:localization.length.modifier.out]].
|
|
| 484 |
| `long double` | `L` |
|
| 485 |
| otherwise | none |
|
| 486 |
|
| 487 |
|
| 488 |
The conversion specifier has the following optional additional
|
| 489 |
-
qualifiers prepended as indicated in
|
| 490 |
-
Table [[tab:localization.numeric.conversions]].
|
| 491 |
|
| 492 |
-
**Table: Numeric conversions** <a id="
|
| 493 |
|
| 494 |
| Type(s) | State | `stdio` equivalent |
|
| 495 |
| --------------------- | ----------- | ------------------ |
|
| 496 |
| an integral type | `showpos` | `+` |
|
| 497 |
| | `showbase` | `#` |
|
|
@@ -511,16 +509,20 @@ would be printed by a call of `printf(s, val)` where `s` is the
|
|
| 511 |
conversion specifier determined above.
|
| 512 |
|
| 513 |
- **Stage 2:**
|
| 514 |
|
| 515 |
Any character `c` other than a decimal point(.) is converted to a
|
| 516 |
-
`charT` via
|
|
|
|
|
|
|
|
|
|
|
|
|
| 517 |
|
| 518 |
A local variable `punct` is initialized via
|
| 519 |
|
| 520 |
``` cpp
|
| 521 |
-
const numpunct<charT>& punct = use_facet<numpunct<charT>>(
|
| 522 |
```
|
| 523 |
|
| 524 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 525 |
into the sequence as determined by the value returned by
|
| 526 |
`punct.do_grouping()` using the method described
|
|
@@ -535,13 +537,13 @@ A local variable is initialized as
|
|
| 535 |
``` cpp
|
| 536 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 537 |
```
|
| 538 |
|
| 539 |
The location of any padding[^12] is determined according to
|
| 540 |
-
|
| 541 |
|
| 542 |
-
**Table: Fill padding** <a id="
|
| 543 |
|
| 544 |
| State | Location |
|
| 545 |
| ------------------------------------------------------------------------------ | ------------------ |
|
| 546 |
| `adjustfield == ios_base::left` | pad after |
|
| 547 |
| `adjustfield == ios_base::right` | pad before |
|
|
|
|
| 5 |
Implementations may (but are not required to) delegate extraction of
|
| 6 |
smaller types to extractors for larger types.[^11]
|
| 7 |
|
| 8 |
All specifications of member functions for `num_put` and `num_get` in
|
| 9 |
the subclauses of [[category.numeric]] only apply to the
|
| 10 |
+
specializations required in Tables [[tab:locale.category.facets]] and
|
| 11 |
+
[[tab:locale.spec]] [[locale.category]], namely `num_get<char>`,
|
| 12 |
+
`num_get<wchar_t>`, `num_get<C, InputIterator>`, `num_put<char>`,
|
| 13 |
+
`num_put<wchar_t>`, and `num_put<C, OutputIterator>`. These
|
| 14 |
+
specializations refer to the `ios_base&` argument for formatting
|
| 15 |
+
specifications [[locale.categories]], and to its imbued locale for the
|
| 16 |
+
`numpunct<>` facet to identify all numeric punctuation preferences, and
|
| 17 |
+
also for the `ctype<>` facet to perform character classification.
|
|
|
|
| 18 |
|
| 19 |
Extractor and inserter members of the standard iostreams use `num_get<>`
|
| 20 |
and `num_put<>` member functions for formatting and parsing numeric
|
| 21 |
values ([[istream.formatted.reqmts]], [[ostream.formatted.reqmts]]).
|
| 22 |
|
|
|
|
| 86 |
```
|
| 87 |
|
| 88 |
The facet `num_get` is used to parse numeric values from an input
|
| 89 |
sequence such as an istream.
|
| 90 |
|
| 91 |
+
##### Members <a id="facet.num.get.members">[[facet.num.get.members]]</a>
|
| 92 |
|
| 93 |
``` cpp
|
| 94 |
iter_type get(iter_type in, iter_type end, ios_base& str,
|
| 95 |
ios_base::iostate& err, bool& val) const;
|
| 96 |
iter_type get(iter_type in, iter_type end, ios_base& str,
|
|
|
|
| 115 |
ios_base::iostate& err, void*& val) const;
|
| 116 |
```
|
| 117 |
|
| 118 |
*Returns:* `do_get(in, end, str, err, val)`.
|
| 119 |
|
| 120 |
+
##### Virtual functions <a id="facet.num.get.virtuals">[[facet.num.get.virtuals]]</a>
|
| 121 |
|
| 122 |
``` cpp
|
| 123 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 124 |
ios_base::iostate& err, long& val) const;
|
| 125 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
|
|
|
| 166 |
fmtflags uppercase = (flags & ios_base::uppercase);
|
| 167 |
fmtflags boolalpha = (flags & ios_base::boolalpha);
|
| 168 |
```
|
| 169 |
|
| 170 |
For conversion to an integral type, the function determines the integral
|
| 171 |
+
conversion specifier as indicated in [[facet.num.get.int]]. The
|
| 172 |
+
table is ordered. That is, the first line whose condition is true
|
| 173 |
+
applies.
|
| 174 |
|
| 175 |
+
**Table: Integer conversions** <a id="facet.num.get.int">[facet.num.get.int]</a>
|
| 176 |
|
| 177 |
| State | `stdio` equivalent |
|
| 178 |
| ------------------------ | ------------------ |
|
| 179 |
| `basefield == oct` | `%o` |
|
| 180 |
| `basefield == hex` | `%X` |
|
| 181 |
| `basefield == 0` | `%i` `signed` integral type | `%d` |
|
| 182 |
| `unsigned` integral type | `%u` |
|
| 183 |
|
| 184 |
|
| 185 |
+
For conversions to a floating-point type the specifier is `%g`.
|
| 186 |
|
| 187 |
For conversions to `void*` the specifier is `%p`.
|
| 188 |
|
| 189 |
A length modifier is added to the conversion specification, if needed,
|
| 190 |
+
as indicated in [[facet.num.get.length]].
|
| 191 |
|
| 192 |
+
**Table: Length modifier** <a id="facet.num.get.length">[facet.num.get.length]</a>
|
| 193 |
|
| 194 |
| Type | Length modifier |
|
| 195 |
| -------------------- | --------------- |
|
| 196 |
| `short` | `h` |
|
| 197 |
| `unsigned short` | `h` |
|
|
|
|
| 359 |
```
|
| 360 |
|
| 361 |
The facet `num_put` is used to format numeric values to a character
|
| 362 |
sequence such as an ostream.
|
| 363 |
|
| 364 |
+
##### Members <a id="facet.num.put.members">[[facet.num.put.members]]</a>
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
|
| 368 |
iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 369 |
iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
|
|
|
| 374 |
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 375 |
```
|
| 376 |
|
| 377 |
*Returns:* `do_put(out, str, fill, val)`.
|
| 378 |
|
| 379 |
+
##### Virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
|
| 380 |
|
| 381 |
``` cpp
|
| 382 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 383 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 384 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
|
|
|
| 387 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 388 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 389 |
```
|
| 390 |
|
| 391 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 392 |
+
desired. In the following description, `loc` names a local variable
|
| 393 |
+
initialized as
|
| 394 |
|
| 395 |
``` cpp
|
| 396 |
locale loc = str.getloc();
|
| 397 |
```
|
| 398 |
|
| 399 |
The details of this operation occur in several stages:
|
| 400 |
|
| 401 |
- Stage 1: Determine a printf conversion specifier `spec` and determine
|
| 402 |
+
the characters that would be printed by `printf` [[c.files]] given
|
| 403 |
this conversion specifier for
|
| 404 |
``` cpp
|
| 405 |
printf(spec, val)
|
| 406 |
```
|
| 407 |
|
| 408 |
assuming that the current locale is the `"C"` locale.
|
| 409 |
- Stage 2: Adjust the representation by converting each `char`
|
| 410 |
determined by stage 1 to a `charT` using a conversion and values
|
| 411 |
+
returned by members of `use_facet<numpunct<charT>>(loc)`.
|
| 412 |
- Stage 3: Determine where padding is required.
|
| 413 |
- Stage 4: Insert the sequence into the `out`.
|
| 414 |
|
| 415 |
Detailed descriptions of each stage follow.
|
| 416 |
|
|
|
|
| 436 |
line whose condition is true applies. A line without a condition is the
|
| 437 |
default behavior when none of the earlier lines apply.
|
| 438 |
|
| 439 |
For conversion from an integral type other than a character type, the
|
| 440 |
function determines the integral conversion specifier as indicated in
|
| 441 |
+
[[facet.num.put.int]].
|
| 442 |
|
| 443 |
+
**Table: Integer conversions** <a id="facet.num.put.int">[facet.num.put.int]</a>
|
| 444 |
|
| 445 |
| State | `stdio` equivalent |
|
| 446 |
| -------------------------------------------- | ------------------ |
|
| 447 |
| `basefield == ios_base::oct` | `%o` |
|
| 448 |
| `(basefield == ios_base::hex) && !uppercase` | `%x` |
|
|
|
|
| 451 |
| for an `unsigned` integral type | `%u` |
|
| 452 |
|
| 453 |
|
| 454 |
For conversion from a floating-point type, the function determines the
|
| 455 |
floating-point conversion specifier as indicated in
|
| 456 |
+
[[facet.num.put.fp]].
|
| 457 |
|
| 458 |
+
**Table: Floating-point conversions** <a id="facet.num.put.fp">[facet.num.put.fp]</a>
|
| 459 |
|
| 460 |
| State | `stdio` equivalent |
|
| 461 |
| ---------------------------------------------------------------------- | ------------------ |
|
| 462 |
| `floatfield == ios_base::fixed` | `%f` |
|
| 463 |
| `floatfield == ios_base::scientific && !uppercase` | `%e` |
|
|
|
|
| 468 |
| otherwise | `%G` |
|
| 469 |
|
| 470 |
|
| 471 |
For conversions from an integral or floating-point type a length
|
| 472 |
modifier is added to the conversion specifier as indicated in
|
| 473 |
+
[[facet.num.put.length]].
|
| 474 |
|
| 475 |
+
**Table: Length modifier** <a id="facet.num.put.length">[facet.num.put.length]</a>
|
| 476 |
|
| 477 |
| Type | Length modifier |
|
| 478 |
| -------------------- | --------------- |
|
| 479 |
| `long` | `l` |
|
| 480 |
| `long long` | `ll` |
|
|
|
|
| 483 |
| `long double` | `L` |
|
| 484 |
| otherwise | none |
|
| 485 |
|
| 486 |
|
| 487 |
The conversion specifier has the following optional additional
|
| 488 |
+
qualifiers prepended as indicated in [[facet.num.put.conv]].
|
|
|
|
| 489 |
|
| 490 |
+
**Table: Numeric conversions** <a id="facet.num.put.conv">[facet.num.put.conv]</a>
|
| 491 |
|
| 492 |
| Type(s) | State | `stdio` equivalent |
|
| 493 |
| --------------------- | ----------- | ------------------ |
|
| 494 |
| an integral type | `showpos` | `+` |
|
| 495 |
| | `showbase` | `#` |
|
|
|
|
| 509 |
conversion specifier determined above.
|
| 510 |
|
| 511 |
- **Stage 2:**
|
| 512 |
|
| 513 |
Any character `c` other than a decimal point(.) is converted to a
|
| 514 |
+
`charT` via
|
| 515 |
+
|
| 516 |
+
``` cpp
|
| 517 |
+
use_facet<ctype<charT>>(loc).widen(c)
|
| 518 |
+
```
|
| 519 |
|
| 520 |
A local variable `punct` is initialized via
|
| 521 |
|
| 522 |
``` cpp
|
| 523 |
+
const numpunct<charT>& punct = use_facet<numpunct<charT>>(loc);
|
| 524 |
```
|
| 525 |
|
| 526 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 527 |
into the sequence as determined by the value returned by
|
| 528 |
`punct.do_grouping()` using the method described
|
|
|
|
| 537 |
``` cpp
|
| 538 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 539 |
```
|
| 540 |
|
| 541 |
The location of any padding[^12] is determined according to
|
| 542 |
+
[[facet.num.put.fill]].
|
| 543 |
|
| 544 |
+
**Table: Fill padding** <a id="facet.num.put.fill">[facet.num.put.fill]</a>
|
| 545 |
|
| 546 |
| State | Location |
|
| 547 |
| ------------------------------------------------------------------------------ | ------------------ |
|
| 548 |
| `adjustfield == ios_base::left` | pad after |
|
| 549 |
| `adjustfield == ios_base::right` | pad before |
|