tmp/tmpxstz72zz/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
#####
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 5 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 6 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
|
@@ -9,30 +9,30 @@ iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const
|
|
| 9 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 10 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 11 |
```
|
| 12 |
|
| 13 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 14 |
-
desired. In the following description, a local variable
|
| 15 |
-
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
locale loc = str.getloc();
|
| 19 |
```
|
| 20 |
|
| 21 |
The details of this operation occur in several stages:
|
| 22 |
|
| 23 |
- Stage 1: Determine a printf conversion specifier `spec` and determine
|
| 24 |
-
the characters that would be printed by `printf`
|
| 25 |
this conversion specifier for
|
| 26 |
``` cpp
|
| 27 |
printf(spec, val)
|
| 28 |
```
|
| 29 |
|
| 30 |
assuming that the current locale is the `"C"` locale.
|
| 31 |
- Stage 2: Adjust the representation by converting each `char`
|
| 32 |
determined by stage 1 to a `charT` using a conversion and values
|
| 33 |
-
returned by members of `use_facet<numpunct<charT>>(
|
| 34 |
- Stage 3: Determine where padding is required.
|
| 35 |
- Stage 4: Insert the sequence into the `out`.
|
| 36 |
|
| 37 |
Detailed descriptions of each stage follow.
|
| 38 |
|
|
@@ -58,13 +58,13 @@ All tables used in describing stage 1 are ordered. That is, the first
|
|
| 58 |
line whose condition is true applies. A line without a condition is the
|
| 59 |
default behavior when none of the earlier lines apply.
|
| 60 |
|
| 61 |
For conversion from an integral type other than a character type, the
|
| 62 |
function determines the integral conversion specifier as indicated in
|
| 63 |
-
|
| 64 |
|
| 65 |
-
**Table: Integer conversions** <a id="
|
| 66 |
|
| 67 |
| State | `stdio` equivalent |
|
| 68 |
| -------------------------------------------- | ------------------ |
|
| 69 |
| `basefield == ios_base::oct` | `%o` |
|
| 70 |
| `(basefield == ios_base::hex) && !uppercase` | `%x` |
|
|
@@ -73,13 +73,13 @@ Table [[tab:localization.integer.conversions.out]].
|
|
| 73 |
| for an `unsigned` integral type | `%u` |
|
| 74 |
|
| 75 |
|
| 76 |
For conversion from a floating-point type, the function determines the
|
| 77 |
floating-point conversion specifier as indicated in
|
| 78 |
-
|
| 79 |
|
| 80 |
-
**Table: Floating-point conversions** <a id="
|
| 81 |
|
| 82 |
| State | `stdio` equivalent |
|
| 83 |
| ---------------------------------------------------------------------- | ------------------ |
|
| 84 |
| `floatfield == ios_base::fixed` | `%f` |
|
| 85 |
| `floatfield == ios_base::scientific && !uppercase` | `%e` |
|
|
@@ -90,13 +90,13 @@ Table [[tab:localization.fp.conversions.out]].
|
|
| 90 |
| otherwise | `%G` |
|
| 91 |
|
| 92 |
|
| 93 |
For conversions from an integral or floating-point type a length
|
| 94 |
modifier is added to the conversion specifier as indicated in
|
| 95 |
-
|
| 96 |
|
| 97 |
-
**Table: Length modifier** <a id="
|
| 98 |
|
| 99 |
| Type | Length modifier |
|
| 100 |
| -------------------- | --------------- |
|
| 101 |
| `long` | `l` |
|
| 102 |
| `long long` | `ll` |
|
|
@@ -105,14 +105,13 @@ Table [[tab:localization.length.modifier.out]].
|
|
| 105 |
| `long double` | `L` |
|
| 106 |
| otherwise | none |
|
| 107 |
|
| 108 |
|
| 109 |
The conversion specifier has the following optional additional
|
| 110 |
-
qualifiers prepended as indicated in
|
| 111 |
-
Table [[tab:localization.numeric.conversions]].
|
| 112 |
|
| 113 |
-
**Table: Numeric conversions** <a id="
|
| 114 |
|
| 115 |
| Type(s) | State | `stdio` equivalent |
|
| 116 |
| --------------------- | ----------- | ------------------ |
|
| 117 |
| an integral type | `showpos` | `+` |
|
| 118 |
| | `showbase` | `#` |
|
|
@@ -132,16 +131,20 @@ would be printed by a call of `printf(s, val)` where `s` is the
|
|
| 132 |
conversion specifier determined above.
|
| 133 |
|
| 134 |
- **Stage 2:**
|
| 135 |
|
| 136 |
Any character `c` other than a decimal point(.) is converted to a
|
| 137 |
-
`charT` via
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
A local variable `punct` is initialized via
|
| 140 |
|
| 141 |
``` cpp
|
| 142 |
-
const numpunct<charT>& punct = use_facet<numpunct<charT>>(
|
| 143 |
```
|
| 144 |
|
| 145 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 146 |
into the sequence as determined by the value returned by
|
| 147 |
`punct.do_grouping()` using the method described
|
|
@@ -156,13 +159,13 @@ A local variable is initialized as
|
|
| 156 |
``` cpp
|
| 157 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 158 |
```
|
| 159 |
|
| 160 |
The location of any padding[^12] is determined according to
|
| 161 |
-
|
| 162 |
|
| 163 |
-
**Table: Fill padding** <a id="
|
| 164 |
|
| 165 |
| State | Location |
|
| 166 |
| ------------------------------------------------------------------------------ | ------------------ |
|
| 167 |
| `adjustfield == ios_base::left` | pad after |
|
| 168 |
| `adjustfield == ios_base::right` | pad before |
|
|
|
|
| 1 |
+
##### Virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 5 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 6 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
|
|
|
| 9 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 10 |
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
| 11 |
```
|
| 12 |
|
| 13 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 14 |
+
desired. In the following description, `loc` names a local variable
|
| 15 |
+
initialized as
|
| 16 |
|
| 17 |
``` cpp
|
| 18 |
locale loc = str.getloc();
|
| 19 |
```
|
| 20 |
|
| 21 |
The details of this operation occur in several stages:
|
| 22 |
|
| 23 |
- Stage 1: Determine a printf conversion specifier `spec` and determine
|
| 24 |
+
the characters that would be printed by `printf` [[c.files]] given
|
| 25 |
this conversion specifier for
|
| 26 |
``` cpp
|
| 27 |
printf(spec, val)
|
| 28 |
```
|
| 29 |
|
| 30 |
assuming that the current locale is the `"C"` locale.
|
| 31 |
- Stage 2: Adjust the representation by converting each `char`
|
| 32 |
determined by stage 1 to a `charT` using a conversion and values
|
| 33 |
+
returned by members of `use_facet<numpunct<charT>>(loc)`.
|
| 34 |
- Stage 3: Determine where padding is required.
|
| 35 |
- Stage 4: Insert the sequence into the `out`.
|
| 36 |
|
| 37 |
Detailed descriptions of each stage follow.
|
| 38 |
|
|
|
|
| 58 |
line whose condition is true applies. A line without a condition is the
|
| 59 |
default behavior when none of the earlier lines apply.
|
| 60 |
|
| 61 |
For conversion from an integral type other than a character type, the
|
| 62 |
function determines the integral conversion specifier as indicated in
|
| 63 |
+
[[facet.num.put.int]].
|
| 64 |
|
| 65 |
+
**Table: Integer conversions** <a id="facet.num.put.int">[facet.num.put.int]</a>
|
| 66 |
|
| 67 |
| State | `stdio` equivalent |
|
| 68 |
| -------------------------------------------- | ------------------ |
|
| 69 |
| `basefield == ios_base::oct` | `%o` |
|
| 70 |
| `(basefield == ios_base::hex) && !uppercase` | `%x` |
|
|
|
|
| 73 |
| for an `unsigned` integral type | `%u` |
|
| 74 |
|
| 75 |
|
| 76 |
For conversion from a floating-point type, the function determines the
|
| 77 |
floating-point conversion specifier as indicated in
|
| 78 |
+
[[facet.num.put.fp]].
|
| 79 |
|
| 80 |
+
**Table: Floating-point conversions** <a id="facet.num.put.fp">[facet.num.put.fp]</a>
|
| 81 |
|
| 82 |
| State | `stdio` equivalent |
|
| 83 |
| ---------------------------------------------------------------------- | ------------------ |
|
| 84 |
| `floatfield == ios_base::fixed` | `%f` |
|
| 85 |
| `floatfield == ios_base::scientific && !uppercase` | `%e` |
|
|
|
|
| 90 |
| otherwise | `%G` |
|
| 91 |
|
| 92 |
|
| 93 |
For conversions from an integral or floating-point type a length
|
| 94 |
modifier is added to the conversion specifier as indicated in
|
| 95 |
+
[[facet.num.put.length]].
|
| 96 |
|
| 97 |
+
**Table: Length modifier** <a id="facet.num.put.length">[facet.num.put.length]</a>
|
| 98 |
|
| 99 |
| Type | Length modifier |
|
| 100 |
| -------------------- | --------------- |
|
| 101 |
| `long` | `l` |
|
| 102 |
| `long long` | `ll` |
|
|
|
|
| 105 |
| `long double` | `L` |
|
| 106 |
| otherwise | none |
|
| 107 |
|
| 108 |
|
| 109 |
The conversion specifier has the following optional additional
|
| 110 |
+
qualifiers prepended as indicated in [[facet.num.put.conv]].
|
|
|
|
| 111 |
|
| 112 |
+
**Table: Numeric conversions** <a id="facet.num.put.conv">[facet.num.put.conv]</a>
|
| 113 |
|
| 114 |
| Type(s) | State | `stdio` equivalent |
|
| 115 |
| --------------------- | ----------- | ------------------ |
|
| 116 |
| an integral type | `showpos` | `+` |
|
| 117 |
| | `showbase` | `#` |
|
|
|
|
| 131 |
conversion specifier determined above.
|
| 132 |
|
| 133 |
- **Stage 2:**
|
| 134 |
|
| 135 |
Any character `c` other than a decimal point(.) is converted to a
|
| 136 |
+
`charT` via
|
| 137 |
+
|
| 138 |
+
``` cpp
|
| 139 |
+
use_facet<ctype<charT>>(loc).widen(c)
|
| 140 |
+
```
|
| 141 |
|
| 142 |
A local variable `punct` is initialized via
|
| 143 |
|
| 144 |
``` cpp
|
| 145 |
+
const numpunct<charT>& punct = use_facet<numpunct<charT>>(loc);
|
| 146 |
```
|
| 147 |
|
| 148 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 149 |
into the sequence as determined by the value returned by
|
| 150 |
`punct.do_grouping()` using the method described
|
|
|
|
| 159 |
``` cpp
|
| 160 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 161 |
```
|
| 162 |
|
| 163 |
The location of any padding[^12] is determined according to
|
| 164 |
+
[[facet.num.put.fill]].
|
| 165 |
|
| 166 |
+
**Table: Fill padding** <a id="facet.num.put.fill">[facet.num.put.fill]</a>
|
| 167 |
|
| 168 |
| State | Location |
|
| 169 |
| ------------------------------------------------------------------------------ | ------------------ |
|
| 170 |
| `adjustfield == ios_base::left` | pad after |
|
| 171 |
| `adjustfield == ios_base::right` | pad before |
|