From Jason Turner

[category.numeric]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpjoth73gz/{from.md → to.md} +17 -16
tmp/tmpjoth73gz/{from.md → to.md} RENAMED
@@ -1,8 +1,8 @@
1
- ### The numeric category <a id="category.numeric">[[category.numeric]]</a>
2
 
3
- #### General <a id="category.numeric.general">[[category.numeric.general]]</a>
4
 
5
  The classes `num_get<>` and `num_put<>` handle numeric formatting and
6
  parsing. Virtual functions are provided for several numeric types.
7
  Implementations may (but are not required to) delegate extraction of
8
  smaller types to extractors for larger types.[^11]
@@ -20,13 +20,13 @@ also for the `ctype<>` facet to perform character classification.
20
 
21
  Extractor and inserter members of the standard iostreams use `num_get<>`
22
  and `num_put<>` member functions for formatting and parsing numeric
23
  values [[istream.formatted.reqmts]], [[ostream.formatted.reqmts]].
24
 
25
- #### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
26
 
27
- ##### General <a id="locale.num.get.general">[[locale.num.get.general]]</a>
28
 
29
  ``` cpp
30
  namespace std {
31
  template<class charT, class InputIterator = istreambuf_iterator<charT>>
32
  class num_get : public locale::facet {
@@ -90,11 +90,11 @@ namespace std {
90
  ```
91
 
92
  The facet `num_get` is used to parse numeric values from an input
93
  sequence such as an istream.
94
 
95
- ##### Members <a id="facet.num.get.members">[[facet.num.get.members]]</a>
96
 
97
  ``` cpp
98
  iter_type get(iter_type in, iter_type end, ios_base& str,
99
  ios_base::iostate& err, bool& val) const;
100
  iter_type get(iter_type in, iter_type end, ios_base& str,
@@ -119,11 +119,11 @@ iter_type get(iter_type in, iter_type end, ios_base& str,
119
  ios_base::iostate& err, void*& val) const;
120
  ```
121
 
122
  *Returns:* `do_get(in, end, str, err, val)`.
123
 
124
- ##### Virtual functions <a id="facet.num.get.virtuals">[[facet.num.get.virtuals]]</a>
125
 
126
  ``` cpp
127
  iter_type do_get(iter_type in, iter_type end, ios_base& str,
128
  ios_base::iostate& err, long& val) const;
129
  iter_type do_get(iter_type in, iter_type end, ios_base& str,
@@ -148,17 +148,17 @@ iter_type do_get(iter_type in, iter_type end, ios_base& str,
148
 
149
  *Effects:* Reads characters from `in`, interpreting them according to
150
  `str.flags()`, `use_facet<ctype<charT>>(loc)`, and
151
  `use_facet<numpunct<charT>>(loc)`, where `loc` is `str.getloc()`.
152
 
153
- The details of this operation occur in three stages
154
 
155
- - Stage 1: Determine a conversion specifier
156
  - Stage 2: Extract characters from `in` and determine a corresponding
157
  `char` value for the format expected by the conversion specification
158
  determined in stage 1.
159
- - Stage 3: Store results
160
 
161
  The details of the stages are presented below.
162
 
163
  [*Example 1*:
164
 
@@ -208,12 +208,12 @@ Otherwise `false` is stored and `ios_base::failbit` is assigned to
208
 
209
  The `in` iterator is always left pointing one position beyond the last
210
  character successfully matched. If `val` is set, then `err` is set to
211
  `str.goodbit`; or to `str.eofbit` if, when seeking another character to
212
  match, it is found that `(in == end)`. If `val` is not set, then `err`
213
- is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
214
- for the failure was that `(in == end)`.
215
 
216
  [*Example 2*: For targets `true`: `"a"` and `false`: `"abb"`, the input
217
  sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
218
  sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
219
  `’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
@@ -221,13 +221,13 @@ sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
221
  targets `("")`, any input sequence yields
222
  `err == str.failbit`. — *end example*]
223
 
224
  *Returns:* `in`.
225
 
226
- #### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
227
 
228
- ##### General <a id="locale.nm.put.general">[[locale.nm.put.general]]</a>
229
 
230
  ``` cpp
231
  namespace std {
232
  template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
233
  class num_put : public locale::facet {
@@ -263,11 +263,11 @@ namespace std {
263
  ```
264
 
265
  The facet `num_put` is used to format numeric values to a character
266
  sequence such as an ostream.
267
 
268
- ##### Members <a id="facet.num.put.members">[[facet.num.put.members]]</a>
269
 
270
  ``` cpp
271
  iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
272
  iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
273
  iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
@@ -278,11 +278,11 @@ iter_type put(iter_type out, ios_base& str, char_type fill, long double val) con
278
  iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
279
  ```
280
 
281
  *Returns:* `do_put(out, str, fill, val)`.
282
 
283
- ##### Virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
284
 
285
  ``` cpp
286
  iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
287
  iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
288
  iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
@@ -361,11 +361,12 @@ floating-point conversion specifier as indicated in
361
 
362
  **Table: Floating-point conversions** <a id="facet.num.put.fp">[facet.num.put.fp]</a>
363
 
364
  | State | `stdio` equivalent |
365
  | ---------------------------------------------------------------------- | ------------------ |
366
- | `floatfield == ios_base::fixed` | `%f` |
 
367
  | `floatfield == ios_base::scientific && !uppercase` | `%e` |
368
  | `floatfield == ios_base::scientific` | `%E` |
369
  | `floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase` | `%a` |
370
  | `floatfield == (ios_base::fixed | ios_base::scientific)` | `%A` |
371
  | `!uppercase` | `%g` |
 
1
+ #### The numeric category <a id="category.numeric">[[category.numeric]]</a>
2
 
3
+ ##### General <a id="category.numeric.general">[[category.numeric.general]]</a>
4
 
5
  The classes `num_get<>` and `num_put<>` handle numeric formatting and
6
  parsing. Virtual functions are provided for several numeric types.
7
  Implementations may (but are not required to) delegate extraction of
8
  smaller types to extractors for larger types.[^11]
 
20
 
21
  Extractor and inserter members of the standard iostreams use `num_get<>`
22
  and `num_put<>` member functions for formatting and parsing numeric
23
  values [[istream.formatted.reqmts]], [[ostream.formatted.reqmts]].
24
 
25
+ ##### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
26
 
27
+ ###### General <a id="locale.num.get.general">[[locale.num.get.general]]</a>
28
 
29
  ``` cpp
30
  namespace std {
31
  template<class charT, class InputIterator = istreambuf_iterator<charT>>
32
  class num_get : public locale::facet {
 
90
  ```
91
 
92
  The facet `num_get` is used to parse numeric values from an input
93
  sequence such as an istream.
94
 
95
+ ###### Members <a id="facet.num.get.members">[[facet.num.get.members]]</a>
96
 
97
  ``` cpp
98
  iter_type get(iter_type in, iter_type end, ios_base& str,
99
  ios_base::iostate& err, bool& val) const;
100
  iter_type get(iter_type in, iter_type end, ios_base& str,
 
119
  ios_base::iostate& err, void*& val) const;
120
  ```
121
 
122
  *Returns:* `do_get(in, end, str, err, val)`.
123
 
124
+ ###### Virtual functions <a id="facet.num.get.virtuals">[[facet.num.get.virtuals]]</a>
125
 
126
  ``` cpp
127
  iter_type do_get(iter_type in, iter_type end, ios_base& str,
128
  ios_base::iostate& err, long& val) const;
129
  iter_type do_get(iter_type in, iter_type end, ios_base& str,
 
148
 
149
  *Effects:* Reads characters from `in`, interpreting them according to
150
  `str.flags()`, `use_facet<ctype<charT>>(loc)`, and
151
  `use_facet<numpunct<charT>>(loc)`, where `loc` is `str.getloc()`.
152
 
153
+ The details of this operation occur in three stages:
154
 
155
+ - Stage 1: Determine a conversion specifier.
156
  - Stage 2: Extract characters from `in` and determine a corresponding
157
  `char` value for the format expected by the conversion specification
158
  determined in stage 1.
159
+ - Stage 3: Store results.
160
 
161
  The details of the stages are presented below.
162
 
163
  [*Example 1*:
164
 
 
208
 
209
  The `in` iterator is always left pointing one position beyond the last
210
  character successfully matched. If `val` is set, then `err` is set to
211
  `str.goodbit`; or to `str.eofbit` if, when seeking another character to
212
  match, it is found that `(in == end)`. If `val` is not set, then `err`
213
+ is set to `str.failbit`; or to `(str.failbit | str.eofbit)` if the
214
+ reason for the failure was that `(in == end)`.
215
 
216
  [*Example 2*: For targets `true`: `"a"` and `false`: `"abb"`, the input
217
  sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
218
  sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
219
  `’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
 
221
  targets `("")`, any input sequence yields
222
  `err == str.failbit`. — *end example*]
223
 
224
  *Returns:* `in`.
225
 
226
+ ##### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
227
 
228
+ ###### General <a id="locale.nm.put.general">[[locale.nm.put.general]]</a>
229
 
230
  ``` cpp
231
  namespace std {
232
  template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
233
  class num_put : public locale::facet {
 
263
  ```
264
 
265
  The facet `num_put` is used to format numeric values to a character
266
  sequence such as an ostream.
267
 
268
+ ###### Members <a id="facet.num.put.members">[[facet.num.put.members]]</a>
269
 
270
  ``` cpp
271
  iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
272
  iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
273
  iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
 
278
  iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
279
  ```
280
 
281
  *Returns:* `do_put(out, str, fill, val)`.
282
 
283
+ ###### Virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
284
 
285
  ``` cpp
286
  iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
287
  iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
288
  iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
 
361
 
362
  **Table: Floating-point conversions** <a id="facet.num.put.fp">[facet.num.put.fp]</a>
363
 
364
  | State | `stdio` equivalent |
365
  | ---------------------------------------------------------------------- | ------------------ |
366
+ | `floatfield == ios_base::fixed && !uppercase` | `%f` |
367
+ | `floatfield == ios_base::fixed` | `%F` |
368
  | `floatfield == ios_base::scientific && !uppercase` | `%e` |
369
  | `floatfield == ios_base::scientific` | `%E` |
370
  | `floatfield == (ios_base::fixed | ios_base::scientific) && !uppercase` | `%a` |
371
  | `floatfield == (ios_base::fixed | ios_base::scientific)` | `%A` |
372
  | `!uppercase` | `%g` |