- tmp/tmpx1_xqppz/{from.md → to.md} +81 -100
tmp/tmpx1_xqppz/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
### The numeric category <a id="category.numeric">[[category.numeric]]</a>
|
| 2 |
|
| 3 |
The classes `num_get<>` and `num_put<>` handle numeric formatting and
|
| 4 |
parsing. Virtual functions are provided for several numeric types.
|
| 5 |
Implementations may (but are not required to) delegate extraction of
|
| 6 |
-
smaller types to extractors for larger types.[^
|
| 7 |
|
| 8 |
All specifications of member functions for `num_put` and `num_get` in
|
| 9 |
the subclauses of [[category.numeric]] only apply to the
|
| 10 |
specializations required in Tables [[tab:localization.category.facets]]
|
| 11 |
and [[tab:localization.required.specializations]] (
|
|
@@ -26,12 +26,12 @@ values ([[istream.formatted.reqmts]], [[ostream.formatted.reqmts]]).
|
|
| 26 |
``` cpp
|
| 27 |
namespace std {
|
| 28 |
template <class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 29 |
class num_get : public locale::facet {
|
| 30 |
public:
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
explicit num_get(size_t refs = 0);
|
| 35 |
|
| 36 |
iter_type get(iter_type in, iter_type end, ios_base&,
|
| 37 |
ios_base::iostate& err, bool& v) const;
|
|
@@ -203,12 +203,12 @@ as indicated in Table [[tab:localization.length.modifier.in]].
|
|
| 203 |
| `double` | `l` |
|
| 204 |
| `long double` | `L` |
|
| 205 |
|
| 206 |
- **Stage 2:**
|
| 207 |
|
| 208 |
-
If `in==end` then stage 2 terminates. Otherwise a `charT` is taken
|
| 209 |
-
`in` and local variables are initialized as if by
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
char_type ct = *in;
|
| 213 |
char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];
|
| 214 |
if (ct == use_facet<numpunct<charT>>(loc).decimal_point())
|
|
@@ -226,11 +226,11 @@ char_type atoms[sizeof(src)];
|
|
| 226 |
use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms);
|
| 227 |
```
|
| 228 |
|
| 229 |
for this value of `loc`.
|
| 230 |
|
| 231 |
-
If `discard` is true, then if `’.’` has not yet been accumulated, then
|
| 232 |
the position of the character is remembered, but the character is
|
| 233 |
otherwise ignored. Otherwise, if `’.’` has already been accumulated, the
|
| 234 |
character is discarded and Stage 2 terminates. If it is not discarded,
|
| 235 |
then a check is made to determine if `c` is allowed as the next
|
| 236 |
character of an input field of the conversion specifier returned by
|
|
@@ -247,54 +247,60 @@ header `<cstdlib>`:
|
|
| 247 |
|
| 248 |
- For a signed integer value, the function `strtoll`.
|
| 249 |
|
| 250 |
- For an unsigned integer value, the function `strtoull`.
|
| 251 |
|
| 252 |
-
- For a
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
The numeric value to be stored can be one of:
|
| 255 |
|
| 256 |
-
- zero, if the conversion function
|
| 257 |
-
`ios_base::failbit` is assigned to `err`.
|
| 258 |
|
| 259 |
-
- the most positive representable value, if the field
|
| 260 |
-
|
| 261 |
-
|
| 262 |
|
| 263 |
-
- the most
|
| 264 |
-
|
| 265 |
-
|
| 266 |
|
| 267 |
- the converted value, otherwise.
|
| 268 |
|
| 269 |
-
The resultant numeric value is stored in `val`.
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
Digit grouping is checked. That is, the positions of discarded
|
| 272 |
separators is examined for consistency with
|
| 273 |
-
`use_facet<numpunct<charT>
|
| 274 |
-
|
| 275 |
|
| 276 |
In any case, if stage 2 processing was terminated by the test for
|
| 277 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
| 278 |
|
| 279 |
``` cpp
|
| 280 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 281 |
ios_base::iostate& err, bool& val) const;
|
| 282 |
```
|
| 283 |
|
| 284 |
-
*Effects:* If `(str
|
| 285 |
proceeds as it would for a `long` except that if a value is being stored
|
| 286 |
into `val`, the value is determined according to the following: If the
|
| 287 |
-
value to be stored is 0 then `false` is stored. If the value is 1 then
|
| 288 |
`true` is stored. Otherwise `true` is stored and `ios_base::failbit` is
|
| 289 |
assigned to `err`.
|
| 290 |
|
| 291 |
Otherwise target sequences are determined “as if” by calling the members
|
| 292 |
`falsename()` and `truename()` of the facet obtained by
|
| 293 |
-
`use_facet<numpunct<charT>
|
| 294 |
-
|
| 295 |
-
|
| 296 |
necessary to identify a unique match. The input iterator `in` is
|
| 297 |
compared to `end` only when necessary to obtain a character. If a target
|
| 298 |
sequence is uniquely matched, `val` is set to the corresponding value.
|
| 299 |
Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
| 300 |
`err`.
|
|
@@ -302,127 +308,102 @@ Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
|
| 302 |
The `in` iterator is always left pointing one position beyond the last
|
| 303 |
character successfully matched. If `val` is set, then `err` is set to
|
| 304 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 305 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 306 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 307 |
-
for the failure was that `(in == end)`.
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
`
|
| 311 |
-
|
| 312 |
-
`
|
| 313 |
-
|
|
|
|
|
|
|
| 314 |
|
| 315 |
*Returns:* `in`.
|
| 316 |
|
| 317 |
#### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
|
| 318 |
|
| 319 |
``` cpp
|
| 320 |
namespace std {
|
| 321 |
template <class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
| 322 |
class num_put : public locale::facet {
|
| 323 |
public:
|
| 324 |
-
|
| 325 |
-
|
| 326 |
|
| 327 |
explicit num_put(size_t refs = 0);
|
| 328 |
|
| 329 |
iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;
|
| 330 |
iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;
|
| 331 |
iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const;
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
double v) const;
|
| 338 |
-
iter_type put(iter_type s, ios_base& f, char_type fill,
|
| 339 |
-
long double v) const;
|
| 340 |
-
iter_type put(iter_type s, ios_base& f, char_type fill,
|
| 341 |
-
const void* v) const;
|
| 342 |
|
| 343 |
static locale::id id;
|
| 344 |
|
| 345 |
protected:
|
| 346 |
~num_put();
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
virtual iter_type do_put(iter_type, ios_base&, char_type fill,
|
| 356 |
-
unsigned long long) const;
|
| 357 |
-
virtual iter_type do_put(iter_type, ios_base&, char_type fill,
|
| 358 |
-
double v) const;
|
| 359 |
-
virtual iter_type do_put(iter_type, ios_base&, char_type fill,
|
| 360 |
-
long double v) const;
|
| 361 |
-
virtual iter_type do_put(iter_type, ios_base&, char_type fill,
|
| 362 |
-
const void* v) const;
|
| 363 |
};
|
| 364 |
}
|
| 365 |
```
|
| 366 |
|
| 367 |
The facet `num_put` is used to format numeric values to a character
|
| 368 |
sequence such as an ostream.
|
| 369 |
|
| 370 |
##### `num_put` members <a id="facet.num.put.members">[[facet.num.put.members]]</a>
|
| 371 |
|
| 372 |
``` cpp
|
| 373 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 374 |
-
|
| 375 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 376 |
-
|
| 377 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 378 |
-
|
| 379 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 380 |
-
|
| 381 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 382 |
-
unsigned long long val) const;
|
| 383 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 384 |
-
double val) const;
|
| 385 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 386 |
-
long double val) const;
|
| 387 |
-
iter_type put(iter_type out, ios_base& str, char_type fill,
|
| 388 |
-
const void* val) const;
|
| 389 |
```
|
| 390 |
|
| 391 |
*Returns:* `do_put(out, str, fill, val)`.
|
| 392 |
|
| 393 |
##### `num_put` virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
|
| 394 |
|
| 395 |
``` cpp
|
| 396 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 397 |
-
|
| 398 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 399 |
-
|
| 400 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 401 |
-
|
| 402 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 403 |
-
unsigned long long val) const;
|
| 404 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 405 |
-
double val) const;
|
| 406 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 407 |
-
long double val) const;
|
| 408 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 409 |
-
const void* val) const;
|
| 410 |
```
|
| 411 |
|
| 412 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 413 |
-
desired. In the following description, a local variable initialized
|
|
|
|
| 414 |
|
| 415 |
``` cpp
|
| 416 |
locale loc = str.getloc();
|
| 417 |
```
|
| 418 |
|
| 419 |
The details of this operation occur in several stages:
|
| 420 |
|
| 421 |
-
- Stage 1: Determine a printf conversion specifier `spec` and
|
| 422 |
-
|
| 423 |
-
|
| 424 |
``` cpp
|
| 425 |
printf(spec, val)
|
| 426 |
```
|
| 427 |
|
| 428 |
assuming that the current locale is the `"C"` locale.
|
|
@@ -447,10 +428,11 @@ fmtflags flags = str.flags() ;
|
|
| 447 |
fmtflags basefield = (flags & (ios_base::basefield));
|
| 448 |
fmtflags uppercase = (flags & (ios_base::uppercase));
|
| 449 |
fmtflags floatfield = (flags & (ios_base::floatfield));
|
| 450 |
fmtflags showpos = (flags & (ios_base::showpos));
|
| 451 |
fmtflags showbase = (flags & (ios_base::showbase));
|
|
|
|
| 452 |
```
|
| 453 |
|
| 454 |
All tables used in describing stage 1 are ordered. That is, the first
|
| 455 |
line whose condition is true applies. A line without a condition is the
|
| 456 |
default behavior when none of the earlier lines apply.
|
|
@@ -508,15 +490,15 @@ qualifiers prepended as indicated in
|
|
| 508 |
Table [[tab:localization.numeric.conversions]].
|
| 509 |
|
| 510 |
**Table: Numeric conversions** <a id="tab:localization.numeric.conversions">[tab:localization.numeric.conversions]</a>
|
| 511 |
|
| 512 |
| Type(s) | State | `stdio` equivalent |
|
| 513 |
-
| --------------------- | -----------
|
| 514 |
-
| an integral type | `
|
| 515 |
-
| | `
|
| 516 |
-
| a floating-point type | `
|
| 517 |
-
| | `
|
| 518 |
|
| 519 |
|
| 520 |
For conversion from a floating-point type, if
|
| 521 |
`floatfield != (ios_base::fixed | ios_base::scientific)`,
|
| 522 |
`str.precision()` is specified as precision in the conversion
|
|
@@ -552,11 +534,11 @@ A local variable is initialized as
|
|
| 552 |
|
| 553 |
``` cpp
|
| 554 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 555 |
```
|
| 556 |
|
| 557 |
-
The location of any padding[^
|
| 558 |
Table [[tab:localization.fill.padding]].
|
| 559 |
|
| 560 |
**Table: Fill padding** <a id="tab:localization.fill.padding">[tab:localization.fill.padding]</a>
|
| 561 |
|
| 562 |
| State | Location |
|
|
@@ -582,12 +564,11 @@ The sequence of `charT`’s at the end of stage 3 are output via
|
|
| 582 |
``` cpp
|
| 583 |
*out++ = c
|
| 584 |
```
|
| 585 |
|
| 586 |
``` cpp
|
| 587 |
-
iter_type do_put(iter_type out, ios_base& str, char_type fill,
|
| 588 |
-
bool val) const;
|
| 589 |
```
|
| 590 |
|
| 591 |
*Returns:* If `(str.flags() & ios_base::boolalpha) == 0` returns
|
| 592 |
`do_put(out, str, fill,`
|
| 593 |
`(int)val)`, otherwise obtains a string `s` as if by
|
|
|
|
| 1 |
### The numeric category <a id="category.numeric">[[category.numeric]]</a>
|
| 2 |
|
| 3 |
The classes `num_get<>` and `num_put<>` handle numeric formatting and
|
| 4 |
parsing. Virtual functions are provided for several numeric types.
|
| 5 |
Implementations may (but are not required to) delegate extraction of
|
| 6 |
+
smaller types to extractors for larger types.[^11]
|
| 7 |
|
| 8 |
All specifications of member functions for `num_put` and `num_get` in
|
| 9 |
the subclauses of [[category.numeric]] only apply to the
|
| 10 |
specializations required in Tables [[tab:localization.category.facets]]
|
| 11 |
and [[tab:localization.required.specializations]] (
|
|
|
|
| 26 |
``` cpp
|
| 27 |
namespace std {
|
| 28 |
template <class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 29 |
class num_get : public locale::facet {
|
| 30 |
public:
|
| 31 |
+
using char_type = charT;
|
| 32 |
+
using iter_type = InputIterator;
|
| 33 |
|
| 34 |
explicit num_get(size_t refs = 0);
|
| 35 |
|
| 36 |
iter_type get(iter_type in, iter_type end, ios_base&,
|
| 37 |
ios_base::iostate& err, bool& v) const;
|
|
|
|
| 203 |
| `double` | `l` |
|
| 204 |
| `long double` | `L` |
|
| 205 |
|
| 206 |
- **Stage 2:**
|
| 207 |
|
| 208 |
+
If `in == end` then stage 2 terminates. Otherwise a `charT` is taken
|
| 209 |
+
from `in` and local variables are initialized as if by
|
| 210 |
|
| 211 |
``` cpp
|
| 212 |
char_type ct = *in;
|
| 213 |
char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];
|
| 214 |
if (ct == use_facet<numpunct<charT>>(loc).decimal_point())
|
|
|
|
| 226 |
use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms);
|
| 227 |
```
|
| 228 |
|
| 229 |
for this value of `loc`.
|
| 230 |
|
| 231 |
+
If `discard` is `true`, then if `’.’` has not yet been accumulated, then
|
| 232 |
the position of the character is remembered, but the character is
|
| 233 |
otherwise ignored. Otherwise, if `’.’` has already been accumulated, the
|
| 234 |
character is discarded and Stage 2 terminates. If it is not discarded,
|
| 235 |
then a check is made to determine if `c` is allowed as the next
|
| 236 |
character of an input field of the conversion specifier returned by
|
|
|
|
| 247 |
|
| 248 |
- For a signed integer value, the function `strtoll`.
|
| 249 |
|
| 250 |
- For an unsigned integer value, the function `strtoull`.
|
| 251 |
|
| 252 |
+
- For a `float` value, the function `strtof`.
|
| 253 |
+
|
| 254 |
+
- For a `double` value, the function `strtod`.
|
| 255 |
+
|
| 256 |
+
- For a `long double` value, the function `strtold`.
|
| 257 |
|
| 258 |
The numeric value to be stored can be one of:
|
| 259 |
|
| 260 |
+
- zero, if the conversion function does not convert the entire field.
|
|
|
|
| 261 |
|
| 262 |
+
- the most positive (or negative) representable value, if the field to
|
| 263 |
+
be converted to a signed integer type represents a value too large
|
| 264 |
+
positive (or negative) to be represented in `val`.
|
| 265 |
|
| 266 |
+
- the most positive representable value, if the field to be converted to
|
| 267 |
+
an unsigned integer type represents a value that cannot be represented
|
| 268 |
+
in `val`.
|
| 269 |
|
| 270 |
- the converted value, otherwise.
|
| 271 |
|
| 272 |
+
The resultant numeric value is stored in `val`. If the conversion
|
| 273 |
+
function does not convert the entire field, or if the field represents a
|
| 274 |
+
value outside the range of representable values, `ios_base::failbit` is
|
| 275 |
+
assigned to `err`.
|
| 276 |
|
| 277 |
Digit grouping is checked. That is, the positions of discarded
|
| 278 |
separators is examined for consistency with
|
| 279 |
+
`use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
|
| 280 |
+
then `ios_base::failbit` is assigned to `err`.
|
| 281 |
|
| 282 |
In any case, if stage 2 processing was terminated by the test for
|
| 283 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
| 284 |
|
| 285 |
``` cpp
|
| 286 |
iter_type do_get(iter_type in, iter_type end, ios_base& str,
|
| 287 |
ios_base::iostate& err, bool& val) const;
|
| 288 |
```
|
| 289 |
|
| 290 |
+
*Effects:* If `(str.flags()&ios_base::boolalpha) == 0` then input
|
| 291 |
proceeds as it would for a `long` except that if a value is being stored
|
| 292 |
into `val`, the value is determined according to the following: If the
|
| 293 |
+
value to be stored is 0 then `false` is stored. If the value is `1` then
|
| 294 |
`true` is stored. Otherwise `true` is stored and `ios_base::failbit` is
|
| 295 |
assigned to `err`.
|
| 296 |
|
| 297 |
Otherwise target sequences are determined “as if” by calling the members
|
| 298 |
`falsename()` and `truename()` of the facet obtained by
|
| 299 |
+
`use_facet<numpunct<charT>>(str.getloc())`. Successive characters in the
|
| 300 |
+
range \[`in`, `end`) (see [[sequence.reqmts]]) are obtained and matched
|
| 301 |
+
against corresponding positions in the target sequences only as
|
| 302 |
necessary to identify a unique match. The input iterator `in` is
|
| 303 |
compared to `end` only when necessary to obtain a character. If a target
|
| 304 |
sequence is uniquely matched, `val` is set to the corresponding value.
|
| 305 |
Otherwise `false` is stored and `ios_base::failbit` is assigned to
|
| 306 |
`err`.
|
|
|
|
| 308 |
The `in` iterator is always left pointing one position beyond the last
|
| 309 |
character successfully matched. If `val` is set, then `err` is set to
|
| 310 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 311 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 312 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 313 |
+
for the failure was that `(in == end)`.
|
| 314 |
+
|
| 315 |
+
[*Example 1*: For targets `true`: `"a"` and `false`: `"abb"`, the input
|
| 316 |
+
sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
|
| 317 |
+
sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
|
| 318 |
+
`’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
|
| 319 |
+
sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
|
| 320 |
+
targets `("")`, any input sequence yields
|
| 321 |
+
`err == str.failbit`. — *end example*]
|
| 322 |
|
| 323 |
*Returns:* `in`.
|
| 324 |
|
| 325 |
#### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
|
| 326 |
|
| 327 |
``` cpp
|
| 328 |
namespace std {
|
| 329 |
template <class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
| 330 |
class num_put : public locale::facet {
|
| 331 |
public:
|
| 332 |
+
using char_type = charT;
|
| 333 |
+
using iter_type = OutputIterator;
|
| 334 |
|
| 335 |
explicit num_put(size_t refs = 0);
|
| 336 |
|
| 337 |
iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const;
|
| 338 |
iter_type put(iter_type s, ios_base& f, char_type fill, long v) const;
|
| 339 |
iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const;
|
| 340 |
+
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const;
|
| 341 |
+
iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long long v) const;
|
| 342 |
+
iter_type put(iter_type s, ios_base& f, char_type fill, double v) const;
|
| 343 |
+
iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const;
|
| 344 |
+
iter_type put(iter_type s, ios_base& f, char_type fill, const void* v) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
static locale::id id;
|
| 347 |
|
| 348 |
protected:
|
| 349 |
~num_put();
|
| 350 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const;
|
| 351 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const;
|
| 352 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, long long v) const;
|
| 353 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long) const;
|
| 354 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long long) const;
|
| 355 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const;
|
| 356 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v) const;
|
| 357 |
+
virtual iter_type do_put(iter_type, ios_base&, char_type fill, const void* v) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
};
|
| 359 |
}
|
| 360 |
```
|
| 361 |
|
| 362 |
The facet `num_put` is used to format numeric values to a character
|
| 363 |
sequence such as an ostream.
|
| 364 |
|
| 365 |
##### `num_put` members <a id="facet.num.put.members">[[facet.num.put.members]]</a>
|
| 366 |
|
| 367 |
``` cpp
|
| 368 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const;
|
| 369 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 370 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 371 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
| 372 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
|
| 373 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, double val) const;
|
| 374 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 375 |
+
iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
```
|
| 377 |
|
| 378 |
*Returns:* `do_put(out, str, fill, val)`.
|
| 379 |
|
| 380 |
##### `num_put` virtual functions <a id="facet.num.put.virtuals">[[facet.num.put.virtuals]]</a>
|
| 381 |
|
| 382 |
``` cpp
|
| 383 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const;
|
| 384 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const;
|
| 385 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const;
|
| 386 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const;
|
| 387 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const;
|
| 388 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const;
|
| 389 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
```
|
| 391 |
|
| 392 |
*Effects:* Writes characters to the sequence `out`, formatting `val` as
|
| 393 |
+
desired. In the following description, a local variable initialized
|
| 394 |
+
with:
|
| 395 |
|
| 396 |
``` cpp
|
| 397 |
locale loc = str.getloc();
|
| 398 |
```
|
| 399 |
|
| 400 |
The details of this operation occur in several stages:
|
| 401 |
|
| 402 |
+
- Stage 1: Determine a printf conversion specifier `spec` and determine
|
| 403 |
+
the characters that would be printed by `printf` ([[c.files]]) given
|
| 404 |
+
this conversion specifier for
|
| 405 |
``` cpp
|
| 406 |
printf(spec, val)
|
| 407 |
```
|
| 408 |
|
| 409 |
assuming that the current locale is the `"C"` locale.
|
|
|
|
| 428 |
fmtflags basefield = (flags & (ios_base::basefield));
|
| 429 |
fmtflags uppercase = (flags & (ios_base::uppercase));
|
| 430 |
fmtflags floatfield = (flags & (ios_base::floatfield));
|
| 431 |
fmtflags showpos = (flags & (ios_base::showpos));
|
| 432 |
fmtflags showbase = (flags & (ios_base::showbase));
|
| 433 |
+
fmtflags showpoint = (flags & (ios_base::showpoint));
|
| 434 |
```
|
| 435 |
|
| 436 |
All tables used in describing stage 1 are ordered. That is, the first
|
| 437 |
line whose condition is true applies. A line without a condition is the
|
| 438 |
default behavior when none of the earlier lines apply.
|
|
|
|
| 490 |
Table [[tab:localization.numeric.conversions]].
|
| 491 |
|
| 492 |
**Table: Numeric conversions** <a id="tab:localization.numeric.conversions">[tab:localization.numeric.conversions]</a>
|
| 493 |
|
| 494 |
| Type(s) | State | `stdio` equivalent |
|
| 495 |
+
| --------------------- | ----------- | ------------------ |
|
| 496 |
+
| an integral type | `showpos` | `+` |
|
| 497 |
+
| | `showbase` | `#` |
|
| 498 |
+
| a floating-point type | `showpos` | `+` |
|
| 499 |
+
| | `showpoint` | `#` |
|
| 500 |
|
| 501 |
|
| 502 |
For conversion from a floating-point type, if
|
| 503 |
`floatfield != (ios_base::fixed | ios_base::scientific)`,
|
| 504 |
`str.precision()` is specified as precision in the conversion
|
|
|
|
| 534 |
|
| 535 |
``` cpp
|
| 536 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 537 |
```
|
| 538 |
|
| 539 |
+
The location of any padding[^12] is determined according to
|
| 540 |
Table [[tab:localization.fill.padding]].
|
| 541 |
|
| 542 |
**Table: Fill padding** <a id="tab:localization.fill.padding">[tab:localization.fill.padding]</a>
|
| 543 |
|
| 544 |
| State | Location |
|
|
|
|
| 564 |
``` cpp
|
| 565 |
*out++ = c
|
| 566 |
```
|
| 567 |
|
| 568 |
``` cpp
|
| 569 |
+
iter_type do_put(iter_type out, ios_base& str, char_type fill, bool val) const;
|
|
|
|
| 570 |
```
|
| 571 |
|
| 572 |
*Returns:* If `(str.flags() & ios_base::boolalpha) == 0` returns
|
| 573 |
`do_put(out, str, fill,`
|
| 574 |
`(int)val)`, otherwise obtains a string `s` as if by
|