From Jason Turner

[locale.num.get]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptrgl2s53/{from.md → to.md} +14 -114
tmp/tmptrgl2s53/{from.md → to.md} RENAMED
@@ -1,7 +1,9 @@
1
  #### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
2
 
 
 
3
  ``` cpp
4
  namespace std {
5
  template<class charT, class InputIterator = istreambuf_iterator<charT>>
6
  class num_get : public locale::facet {
7
  public:
@@ -132,129 +134,27 @@ The details of this operation occur in three stages
132
  determined in stage 1.
133
  - Stage 3: Store results
134
 
135
  The details of the stages are presented below.
136
 
137
- - **Stage 1:**
138
 
139
- The function initializes local variables via
140
 
141
- ``` cpp
142
- fmtflags flags = str.flags();
143
- fmtflags basefield = (flags & ios_base::basefield);
144
- fmtflags uppercase = (flags & ios_base::uppercase);
145
- fmtflags boolalpha = (flags & ios_base::boolalpha);
146
- ```
147
 
148
- For conversion to an integral type, the function determines the integral
149
- conversion specifier as indicated in [[facet.num.get.int]]. The
150
- table is ordered. That is, the first line whose condition is true
151
- applies.
152
 
153
- **Table: Integer conversions** <a id="facet.num.get.int">[facet.num.get.int]</a>
154
-
155
- | State | `stdio` equivalent |
156
- | ------------------------ | ------------------ |
157
- | `basefield == oct` | `%o` |
158
- | `basefield == hex` | `%X` |
159
- | `basefield == 0` | `%i` `signed` integral type | `%d` |
160
- | `unsigned` integral type | `%u` |
161
-
162
-
163
- For conversions to a floating-point type the specifier is `%g`.
164
-
165
- For conversions to `void*` the specifier is `%p`.
166
-
167
- A length modifier is added to the conversion specification, if needed,
168
- as indicated in [[facet.num.get.length]].
169
-
170
- **Table: Length modifier** <a id="facet.num.get.length">[facet.num.get.length]</a>
171
-
172
- | Type | Length modifier |
173
- | -------------------- | --------------- |
174
- | `short` | `h` |
175
- | `unsigned short` | `h` |
176
- | `long` | `l` |
177
- | `unsigned long` | `l` |
178
- | `long long` | `ll` |
179
- | `unsigned long long` | `ll` |
180
- | `double` | `l` |
181
- | `long double` | `L` |
182
-
183
- - **Stage 2:**
184
-
185
- If `in == end` then stage 2 terminates. Otherwise a `charT` is taken
186
- from `in` and local variables are initialized as if by
187
-
188
- ``` cpp
189
- char_type ct = *in;
190
- char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];
191
- if (ct == use_facet<numpunct<charT>>(loc).decimal_point())
192
- c = '.';
193
- bool discard =
194
- ct == use_facet<numpunct<charT>>(loc).thousands_sep()
195
- && use_facet<numpunct<charT>>(loc).grouping().length() != 0;
196
- ```
197
-
198
- where the values `src` and `atoms` are defined as if by:
199
-
200
- ``` cpp
201
- static const char src[] = "0123456789abcdefxABCDEFX+-";
202
- char_type atoms[sizeof(src)];
203
- use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms);
204
- ```
205
-
206
- for this value of `loc`.
207
-
208
- If `discard` is `true`, then if `’.’` has not yet been accumulated, then
209
- the position of the character is remembered, but the character is
210
- otherwise ignored. Otherwise, if `’.’` has already been accumulated, the
211
- character is discarded and Stage 2 terminates. If it is not discarded,
212
- then a check is made to determine if `c` is allowed as the next
213
- character of an input field of the conversion specifier returned by
214
- Stage 1. If so, it is accumulated.
215
-
216
- If the character is either discarded or accumulated then `in` is
217
- advanced by `++in` and processing returns to the beginning of stage 2.
218
-
219
- - **Stage 3:**
220
-
221
- The sequence of `char`s accumulated in stage 2 (the field) is converted
222
- to a numeric value by the rules of one of the functions declared in the
223
- header `<cstdlib>`:
224
-
225
- - For a signed integer value, the function `strtoll`.
226
-
227
- - For an unsigned integer value, the function `strtoull`.
228
-
229
- - For a `float` value, the function `strtof`.
230
-
231
- - For a `double` value, the function `strtod`.
232
-
233
- - For a `long double` value, the function `strtold`.
234
-
235
- The numeric value to be stored can be one of:
236
-
237
- - zero, if the conversion function does not convert the entire field.
238
-
239
- - the most positive (or negative) representable value, if the field to
240
- be converted to a signed integer type represents a value too large
241
- positive (or negative) to be represented in `val`.
242
-
243
- - the most positive representable value, if the field to be converted to
244
- an unsigned integer type represents a value that cannot be represented
245
- in `val`.
246
-
247
- - the converted value, otherwise.
248
-
249
- The resultant numeric value is stored in `val`. If the conversion
250
- function does not convert the entire field, or if the field represents a
251
- value outside the range of representable values, `ios_base::failbit` is
252
- assigned to `err`.
253
 
254
  Digit grouping is checked. That is, the positions of discarded
255
- separators is examined for consistency with
256
  `use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
257
  then `ios_base::failbit` is assigned to `err`.
258
 
259
  In any case, if stage 2 processing was terminated by the test for
260
  `in == end` then `err |= ios_base::eofbit` is performed.
@@ -287,11 +187,11 @@ character successfully matched. If `val` is set, then `err` is set to
287
  `str.goodbit`; or to `str.eofbit` if, when seeking another character to
288
  match, it is found that `(in == end)`. If `val` is not set, then `err`
289
  is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
290
  for the failure was that `(in == end)`.
291
 
292
- [*Example 1*: For targets `true`: `"a"` and `false`: `"abb"`, the input
293
  sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
294
  sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
295
  `’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
296
  sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
297
  targets `("")`, any input sequence yields
 
1
  #### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
2
 
3
+ ##### General <a id="locale.num.get.general">[[locale.num.get.general]]</a>
4
+
5
  ``` cpp
6
  namespace std {
7
  template<class charT, class InputIterator = istreambuf_iterator<charT>>
8
  class num_get : public locale::facet {
9
  public:
 
134
  determined in stage 1.
135
  - Stage 3: Store results
136
 
137
  The details of the stages are presented below.
138
 
139
+ [*Example 1*:
140
 
141
+ Given an input sequence of `"0x1a.bp+07p"`,
142
 
143
+ - if the conversion specifier returned by Stage 1 is `%d`, `"0"` is
144
+ accumulated;
145
+ - if the conversion specifier returned by Stage 1 is `%i`, `"0x1a"` are
146
+ accumulated;
147
+ - if the conversion specifier returned by Stage 1 is `%g`,
148
+ `"0x1a.bp+07"` are accumulated.
149
 
150
+ In all cases, the remainder is left in the input.
 
 
 
151
 
152
+ *end example*]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
  Digit grouping is checked. That is, the positions of discarded
155
+ separators are examined for consistency with
156
  `use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
157
  then `ios_base::failbit` is assigned to `err`.
158
 
159
  In any case, if stage 2 processing was terminated by the test for
160
  `in == end` then `err |= ios_base::eofbit` is performed.
 
187
  `str.goodbit`; or to `str.eofbit` if, when seeking another character to
188
  match, it is found that `(in == end)`. If `val` is not set, then `err`
189
  is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
190
  for the failure was that `(in == end)`.
191
 
192
+ [*Example 2*: For targets `true`: `"a"` and `false`: `"abb"`, the input
193
  sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
194
  sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
195
  `’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
196
  sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
197
  targets `("")`, any input sequence yields