tmp/tmpolq6r251/{from.md → to.md}
RENAMED
|
@@ -3,12 +3,12 @@
|
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 6 |
class num_get : public locale::facet {
|
| 7 |
public:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
| 11 |
explicit num_get(size_t refs = 0);
|
| 12 |
|
| 13 |
iter_type get(iter_type in, iter_type end, ios_base&,
|
| 14 |
ios_base::iostate& err, bool& v) const;
|
|
@@ -180,12 +180,12 @@ as indicated in Table [[tab:localization.length.modifier.in]].
|
|
| 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 |
-
`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())
|
|
@@ -203,11 +203,11 @@ 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
|
|
@@ -224,54 +224,60 @@ 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
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
|
| 231 |
The numeric value to be stored can be one of:
|
| 232 |
|
| 233 |
-
- zero, if the conversion function
|
| 234 |
-
`ios_base::failbit` is assigned to `err`.
|
| 235 |
|
| 236 |
-
- the most positive representable value, if the field
|
| 237 |
-
|
| 238 |
-
|
| 239 |
|
| 240 |
-
- the most
|
| 241 |
-
|
| 242 |
-
|
| 243 |
|
| 244 |
- the converted value, otherwise.
|
| 245 |
|
| 246 |
-
The resultant numeric value is stored in `val`.
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
Digit grouping is checked. That is, the positions of discarded
|
| 249 |
separators is examined for consistency with
|
| 250 |
-
`use_facet<numpunct<charT>
|
| 251 |
-
|
| 252 |
|
| 253 |
In any case, if stage 2 processing was terminated by the test for
|
| 254 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
| 255 |
|
| 256 |
``` cpp
|
| 257 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 258 |
ios_base::iostate& err, bool& val) const;
|
| 259 |
```
|
| 260 |
|
| 261 |
-
*Effects:* If `(str
|
| 262 |
proceeds as it would for a `long` except that if a value is being stored
|
| 263 |
into `val`, the value is determined according to the following: If the
|
| 264 |
-
value to be stored is 0 then `false` is stored. If the value is 1 then
|
| 265 |
`true` is stored. Otherwise `true` is stored and `ios_base::failbit` is
|
| 266 |
assigned to `err`.
|
| 267 |
|
| 268 |
Otherwise target sequences are determined “as if” by calling the members
|
| 269 |
`falsename()` and `truename()` of the facet obtained by
|
| 270 |
-
`use_facet<numpunct<charT>
|
| 271 |
-
|
| 272 |
-
|
| 273 |
necessary to identify a unique match. The input iterator `in` is
|
| 274 |
compared to `end` only when necessary to obtain a character. If a target
|
| 275 |
sequence is uniquely matched, `val` is set to the corresponding value.
|
| 276 |
Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
| 277 |
`err`.
|
|
@@ -279,15 +285,17 @@ Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
|
| 279 |
The `in` iterator is always left pointing one position beyond the last
|
| 280 |
character successfully matched. If `val` is set, then `err` is set to
|
| 281 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 282 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 283 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 284 |
-
for the failure was that `(in == end)`.
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
`
|
| 288 |
-
|
| 289 |
-
`
|
| 290 |
-
|
|
|
|
|
|
|
| 291 |
|
| 292 |
*Returns:* `in`.
|
| 293 |
|
|
|
|
| 3 |
``` cpp
|
| 4 |
namespace std {
|
| 5 |
template <class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 6 |
class num_get : public locale::facet {
|
| 7 |
public:
|
| 8 |
+
using char_type = charT;
|
| 9 |
+
using iter_type = InputIterator;
|
| 10 |
|
| 11 |
explicit num_get(size_t refs = 0);
|
| 12 |
|
| 13 |
iter_type get(iter_type in, iter_type end, ios_base&,
|
| 14 |
ios_base::iostate& err, bool& v) const;
|
|
|
|
| 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())
|
|
|
|
| 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
|
|
|
|
| 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.
|
| 261 |
|
| 262 |
``` cpp
|
| 263 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 264 |
ios_base::iostate& err, bool& val) const;
|
| 265 |
```
|
| 266 |
|
| 267 |
+
*Effects:* If `(str.flags()&ios_base::boolalpha) == 0` then input
|
| 268 |
proceeds as it would for a `long` except that if a value is being stored
|
| 269 |
into `val`, the value is determined according to the following: If the
|
| 270 |
+
value to be stored is 0 then `false` is stored. If the value is `1` then
|
| 271 |
`true` is stored. Otherwise `true` is stored and `ios_base::failbit` is
|
| 272 |
assigned to `err`.
|
| 273 |
|
| 274 |
Otherwise target sequences are determined “as if” by calling the members
|
| 275 |
`falsename()` and `truename()` of the facet obtained by
|
| 276 |
+
`use_facet<numpunct<charT>>(str.getloc())`. Successive characters in the
|
| 277 |
+
range \[`in`, `end`) (see [[sequence.reqmts]]) are obtained and matched
|
| 278 |
+
against corresponding positions in the target sequences only as
|
| 279 |
necessary to identify a unique match. The input iterator `in` is
|
| 280 |
compared to `end` only when necessary to obtain a character. If a target
|
| 281 |
sequence is uniquely matched, `val` is set to the corresponding value.
|
| 282 |
Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
| 283 |
`err`.
|
|
|
|
| 285 |
The `in` iterator is always left pointing one position beyond the last
|
| 286 |
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
|
| 298 |
+
`err == str.failbit`. — *end example*]
|
| 299 |
|
| 300 |
*Returns:* `in`.
|
| 301 |
|