- tmp/tmpfrmr6ni8/{from.md → to.md} +12 -114
tmp/tmpfrmr6ni8/{from.md → to.md}
RENAMED
|
@@ -35,129 +35,27 @@ The details of this operation occur in three stages
|
|
| 35 |
determined in stage 1.
|
| 36 |
- Stage 3: Store results
|
| 37 |
|
| 38 |
The details of the stages are presented below.
|
| 39 |
|
| 40 |
-
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
``
|
| 50 |
|
| 51 |
-
|
| 52 |
-
conversion specifier as indicated in [[facet.num.get.int]]. The
|
| 53 |
-
table is ordered. That is, the first line whose condition is true
|
| 54 |
-
applies.
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
| State | `stdio` equivalent |
|
| 59 |
-
| ------------------------ | ------------------ |
|
| 60 |
-
| `basefield == oct` | `%o` |
|
| 61 |
-
| `basefield == hex` | `%X` |
|
| 62 |
-
| `basefield == 0` | `%i` `signed` integral type | `%d` |
|
| 63 |
-
| `unsigned` integral type | `%u` |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
For conversions to a floating-point type the specifier is `%g`.
|
| 67 |
-
|
| 68 |
-
For conversions to `void*` the specifier is `%p`.
|
| 69 |
-
|
| 70 |
-
A length modifier is added to the conversion specification, if needed,
|
| 71 |
-
as indicated in [[facet.num.get.length]].
|
| 72 |
-
|
| 73 |
-
**Table: Length modifier** <a id="facet.num.get.length">[facet.num.get.length]</a>
|
| 74 |
-
|
| 75 |
-
| Type | Length modifier |
|
| 76 |
-
| -------------------- | --------------- |
|
| 77 |
-
| `short` | `h` |
|
| 78 |
-
| `unsigned short` | `h` |
|
| 79 |
-
| `long` | `l` |
|
| 80 |
-
| `unsigned long` | `l` |
|
| 81 |
-
| `long long` | `ll` |
|
| 82 |
-
| `unsigned long long` | `ll` |
|
| 83 |
-
| `double` | `l` |
|
| 84 |
-
| `long double` | `L` |
|
| 85 |
-
|
| 86 |
-
- **Stage 2:**
|
| 87 |
-
|
| 88 |
-
If `in == end` then stage 2 terminates. Otherwise a `charT` is taken
|
| 89 |
-
from `in` and local variables are initialized as if by
|
| 90 |
-
|
| 91 |
-
``` cpp
|
| 92 |
-
char_type ct = *in;
|
| 93 |
-
char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];
|
| 94 |
-
if (ct == use_facet<numpunct<charT>>(loc).decimal_point())
|
| 95 |
-
c = '.';
|
| 96 |
-
bool discard =
|
| 97 |
-
ct == use_facet<numpunct<charT>>(loc).thousands_sep()
|
| 98 |
-
&& use_facet<numpunct<charT>>(loc).grouping().length() != 0;
|
| 99 |
-
```
|
| 100 |
-
|
| 101 |
-
where the values `src` and `atoms` are defined as if by:
|
| 102 |
-
|
| 103 |
-
``` cpp
|
| 104 |
-
static const char src[] = "0123456789abcdefxABCDEFX+-";
|
| 105 |
-
char_type atoms[sizeof(src)];
|
| 106 |
-
use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms);
|
| 107 |
-
```
|
| 108 |
-
|
| 109 |
-
for this value of `loc`.
|
| 110 |
-
|
| 111 |
-
If `discard` is `true`, then if `’.’` has not yet been accumulated, then
|
| 112 |
-
the position of the character is remembered, but the character is
|
| 113 |
-
otherwise ignored. Otherwise, if `’.’` has already been accumulated, the
|
| 114 |
-
character is discarded and Stage 2 terminates. If it is not discarded,
|
| 115 |
-
then a check is made to determine if `c` is allowed as the next
|
| 116 |
-
character of an input field of the conversion specifier returned by
|
| 117 |
-
Stage 1. If so, it is accumulated.
|
| 118 |
-
|
| 119 |
-
If the character is either discarded or accumulated then `in` is
|
| 120 |
-
advanced by `++in` and processing returns to the beginning of stage 2.
|
| 121 |
-
|
| 122 |
-
- **Stage 3:**
|
| 123 |
-
|
| 124 |
-
The sequence of `char`s accumulated in stage 2 (the field) is converted
|
| 125 |
-
to a numeric value by the rules of one of the functions declared in the
|
| 126 |
-
header `<cstdlib>`:
|
| 127 |
-
|
| 128 |
-
- For a signed integer value, the function `strtoll`.
|
| 129 |
-
|
| 130 |
-
- For an unsigned integer value, the function `strtoull`.
|
| 131 |
-
|
| 132 |
-
- For a `float` value, the function `strtof`.
|
| 133 |
-
|
| 134 |
-
- For a `double` value, the function `strtod`.
|
| 135 |
-
|
| 136 |
-
- For a `long double` value, the function `strtold`.
|
| 137 |
-
|
| 138 |
-
The numeric value to be stored can be one of:
|
| 139 |
-
|
| 140 |
-
- zero, if the conversion function does not convert the entire field.
|
| 141 |
-
|
| 142 |
-
- the most positive (or negative) representable value, if the field to
|
| 143 |
-
be converted to a signed integer type represents a value too large
|
| 144 |
-
positive (or negative) to be represented in `val`.
|
| 145 |
-
|
| 146 |
-
- the most positive representable value, if the field to be converted to
|
| 147 |
-
an unsigned integer type represents a value that cannot be represented
|
| 148 |
-
in `val`.
|
| 149 |
-
|
| 150 |
-
- the converted value, otherwise.
|
| 151 |
-
|
| 152 |
-
The resultant numeric value is stored in `val`. If the conversion
|
| 153 |
-
function does not convert the entire field, or if the field represents a
|
| 154 |
-
value outside the range of representable values, `ios_base::failbit` is
|
| 155 |
-
assigned to `err`.
|
| 156 |
|
| 157 |
Digit grouping is checked. That is, the positions of discarded
|
| 158 |
-
separators
|
| 159 |
`use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
|
| 160 |
then `ios_base::failbit` is assigned to `err`.
|
| 161 |
|
| 162 |
In any case, if stage 2 processing was terminated by the test for
|
| 163 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
|
@@ -190,11 +88,11 @@ character successfully matched. If `val` is set, then `err` is set to
|
|
| 190 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 191 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 192 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 193 |
for the failure was that `(in == end)`.
|
| 194 |
|
| 195 |
-
[*Example
|
| 196 |
sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
|
| 197 |
sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
|
| 198 |
`’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
|
| 199 |
sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
|
| 200 |
targets `("")`, any input sequence yields
|
|
|
|
| 35 |
determined in stage 1.
|
| 36 |
- Stage 3: Store results
|
| 37 |
|
| 38 |
The details of the stages are presented below.
|
| 39 |
|
| 40 |
+
[*Example 1*:
|
| 41 |
|
| 42 |
+
Given an input sequence of `"0x1a.bp+07p"`,
|
| 43 |
|
| 44 |
+
- if the conversion specifier returned by Stage 1 is `%d`, `"0"` is
|
| 45 |
+
accumulated;
|
| 46 |
+
- if the conversion specifier returned by Stage 1 is `%i`, `"0x1a"` are
|
| 47 |
+
accumulated;
|
| 48 |
+
- if the conversion specifier returned by Stage 1 is `%g`,
|
| 49 |
+
`"0x1a.bp+07"` are accumulated.
|
| 50 |
|
| 51 |
+
In all cases, the remainder is left in the input.
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
+
— *end example*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
Digit grouping is checked. That is, the positions of discarded
|
| 56 |
+
separators are examined for consistency with
|
| 57 |
`use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
|
| 58 |
then `ios_base::failbit` is assigned to `err`.
|
| 59 |
|
| 60 |
In any case, if stage 2 processing was terminated by the test for
|
| 61 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
|
|
|
| 88 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 89 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 90 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 91 |
for the failure was that `(in == end)`.
|
| 92 |
|
| 93 |
+
[*Example 2*: For targets `true`: `"a"` and `false`: `"abb"`, the input
|
| 94 |
sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
|
| 95 |
sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
|
| 96 |
`’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
|
| 97 |
sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
|
| 98 |
targets `("")`, any input sequence yields
|