tmp/tmpnf9rsqdm/{from.md → to.md}
RENAMED
|
@@ -3,14 +3,13 @@
|
|
| 3 |
These templates handle monetary formats. A template parameter indicates
|
| 4 |
whether local or international monetary formats are to be used.
|
| 5 |
|
| 6 |
All specifications of member functions for `money_put` and `money_get`
|
| 7 |
in the subclauses of [[category.monetary]] only apply to the
|
| 8 |
-
specializations required in Tables [[tab:
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
`ios_base::iostate&`, and `fill` arguments as described in
|
| 12 |
[[locale.categories]], and the `moneypunct<>` and `ctype<>` facets, to
|
| 13 |
determine formatting details.
|
| 14 |
|
| 15 |
#### Class template `money_get` <a id="locale.money.get">[[locale.money.get]]</a>
|
| 16 |
|
|
@@ -42,31 +41,28 @@ namespace std {
|
|
| 42 |
ios_base::iostate& err, string_type& digits) const;
|
| 43 |
};
|
| 44 |
}
|
| 45 |
```
|
| 46 |
|
| 47 |
-
#####
|
| 48 |
|
| 49 |
``` cpp
|
| 50 |
-
iter_type get(iter_type s, iter_type end, bool intl,
|
| 51 |
-
ios_base
|
| 52 |
-
|
| 53 |
-
iter_type get(s, iter_type end, bool intl, ios_base&f,
|
| 54 |
ios_base::iostate& err, string_type& quant) const;
|
| 55 |
```
|
| 56 |
|
| 57 |
*Returns:* `do_get(s, end, intl, f, err, quant)`.
|
| 58 |
|
| 59 |
-
#####
|
| 60 |
|
| 61 |
``` cpp
|
| 62 |
-
iter_type do_get(iter_type s, iter_type end, bool intl,
|
| 63 |
-
ios_base
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
ios_base& str, ios_base::iostate& err,
|
| 67 |
-
string_type& digits) const;
|
| 68 |
```
|
| 69 |
|
| 70 |
*Effects:* Reads characters from `s` to parse and construct a monetary
|
| 71 |
value according to the format specified by a `moneypunct<charT, Intl>`
|
| 72 |
facet reference `mp` and the character mapping specified by a
|
|
@@ -76,11 +72,11 @@ does not change `err`; otherwise, sets `err` to `(err|str.failbit)`, or
|
|
| 76 |
`(err|str.failbit|str.eofbit)` if no more characters are available, and
|
| 77 |
does not change `units` or `digits`. Uses the pattern returned by
|
| 78 |
`mp.neg_format()` to parse all values. The result is returned as an
|
| 79 |
integral value stored in `units` or as a sequence of digits possibly
|
| 80 |
preceded by a minus sign (as produced by `ct.widen(c)` where `c` is
|
| 81 |
-
`’-’` or in the range from `’0’` through `’9’`
|
| 82 |
`digits`.
|
| 83 |
|
| 84 |
[*Example 1*: The sequence `$1,056.23` in a common United States locale
|
| 85 |
would yield, for `units`, `105623`, or, for `digits`,
|
| 86 |
`"105623"`. — *end example*]
|
|
@@ -95,13 +91,13 @@ Where `money_base::space` or `money_base::none` appears as the last
|
|
| 95 |
element in the format pattern, no white space is consumed. Otherwise,
|
| 96 |
where `money_base::space` appears in any of the initial elements of the
|
| 97 |
format pattern, at least one white space character is required. Where
|
| 98 |
`money_base::none` appears in any of the initial elements of the format
|
| 99 |
pattern, white space is allowed but not required. If
|
| 100 |
-
`(str.flags() & str.showbase)` is false, the currency symbol is
|
| 101 |
-
and is consumed only if other characters are needed to complete
|
| 102 |
-
format; otherwise, the currency symbol is required.
|
| 103 |
|
| 104 |
If the first character (if any) in the string `pos` returned by
|
| 105 |
`mp.positive_sign()` or the string `neg` returned by
|
| 106 |
`mp.negative_sign()` is recognized in the position indicated by `sign`
|
| 107 |
in the format pattern, it is consumed and any remaining characters in
|
|
@@ -173,22 +169,20 @@ namespace std {
|
|
| 173 |
const string_type& digits) const;
|
| 174 |
};
|
| 175 |
}
|
| 176 |
```
|
| 177 |
|
| 178 |
-
#####
|
| 179 |
|
| 180 |
``` cpp
|
| 181 |
-
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
|
| 182 |
-
|
| 183 |
-
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
|
| 184 |
-
const string_type& quant) const;
|
| 185 |
```
|
| 186 |
|
| 187 |
*Returns:* `do_put(s, intl, f, loc, quant)`.
|
| 188 |
|
| 189 |
-
#####
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
iter_type do_put(iter_type s, bool intl, ios_base& str,
|
| 193 |
char_type fill, long double units) const;
|
| 194 |
iter_type do_put(iter_type s, bool intl, ios_base& str,
|
|
@@ -282,11 +276,11 @@ namespace std {
|
|
| 282 |
```
|
| 283 |
|
| 284 |
The `moneypunct<>` facet defines monetary formatting parameters used by
|
| 285 |
`money_get<>` and `money_put<>`. A monetary format is a sequence of four
|
| 286 |
components, specified by a `pattern` value `p`, such that the `part`
|
| 287 |
-
value `static_cast<part>(p.field[i])` determines the `i`
|
| 288 |
the format[^21] In the `field` member of a `pattern` object, each value
|
| 289 |
`symbol`, `sign`, `value`, and either `space` or `none` appears exactly
|
| 290 |
once. The value `none`, if present, is not first; the value `space`, if
|
| 291 |
present, is neither first nor last.
|
| 292 |
|
|
@@ -302,44 +296,57 @@ required. Any remaining characters of the sign sequence are required
|
|
| 302 |
after all other format components. Where `value` appears, the absolute
|
| 303 |
numeric monetary value is required.
|
| 304 |
|
| 305 |
The format of the numeric monetary value is a decimal number:
|
| 306 |
|
| 307 |
-
```
|
| 308 |
-
value
|
|
|
|
| 309 |
decimal-point digits
|
| 310 |
```
|
| 311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
if `frac_digits()` returns a positive value, or
|
| 313 |
|
| 314 |
-
```
|
| 315 |
-
value
|
|
|
|
| 316 |
```
|
| 317 |
|
| 318 |
-
otherwise. The symbol
|
| 319 |
-
|
| 320 |
|
| 321 |
-
```
|
| 322 |
-
units
|
| 323 |
-
digits
|
|
|
|
| 324 |
```
|
| 325 |
|
| 326 |
-
|
| 327 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
`ct` is a reference of type `const ctype<charT>&` obtained as described
|
| 329 |
-
in the definitions of `money_get<>` and `money_put<>`. The symbol
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
|
| 336 |
The placement of thousands-separator characters (if any) is determined
|
| 337 |
by the value returned by `grouping()`, defined identically as the member
|
| 338 |
`numpunct<>::do_grouping()`.
|
| 339 |
|
| 340 |
-
#####
|
| 341 |
|
| 342 |
``` cpp
|
| 343 |
charT decimal_point() const;
|
| 344 |
charT thousands_sep() const;
|
| 345 |
string grouping() const;
|
|
@@ -352,11 +359,11 @@ pattern neg_format() const;
|
|
| 352 |
```
|
| 353 |
|
| 354 |
Each of these functions `F` returns the result of calling the
|
| 355 |
corresponding virtual member function `do_F()`.
|
| 356 |
|
| 357 |
-
#####
|
| 358 |
|
| 359 |
``` cpp
|
| 360 |
charT do_decimal_point() const;
|
| 361 |
```
|
| 362 |
|
|
@@ -379,39 +386,47 @@ to, the result of `numpunct<charT>::do_grouping()`.[^24]
|
|
| 379 |
|
| 380 |
``` cpp
|
| 381 |
string_type do_curr_symbol() const;
|
| 382 |
```
|
| 383 |
|
| 384 |
-
*Returns:* A string to use as the currency identifier symbol.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
| 386 |
``` cpp
|
| 387 |
string_type do_positive_sign() const;
|
| 388 |
string_type do_negative_sign() const;
|
| 389 |
```
|
| 390 |
|
| 391 |
*Returns:* `do_positive_sign()` returns the string to use to indicate a
|
| 392 |
-
positive monetary value;[^
|
| 393 |
use to indicate a negative value.
|
| 394 |
|
| 395 |
``` cpp
|
| 396 |
int do_frac_digits() const;
|
| 397 |
```
|
| 398 |
|
| 399 |
*Returns:* The number of digits after the decimal radix separator, if
|
| 400 |
-
any.[^
|
| 401 |
|
| 402 |
``` cpp
|
| 403 |
pattern do_pos_format() const;
|
| 404 |
pattern do_neg_format() const;
|
| 405 |
```
|
| 406 |
|
| 407 |
*Returns:* The specializations required in
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
`moneypunct<char
|
| 411 |
-
|
| 412 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
| 414 |
#### Class template `moneypunct_byname` <a id="locale.moneypunct.byname">[[locale.moneypunct.byname]]</a>
|
| 415 |
|
| 416 |
``` cpp
|
| 417 |
namespace std {
|
|
@@ -421,10 +436,11 @@ namespace std {
|
|
| 421 |
using pattern = money_base::pattern;
|
| 422 |
using string_type = basic_string<charT>;
|
| 423 |
|
| 424 |
explicit moneypunct_byname(const char*, size_t refs = 0);
|
| 425 |
explicit moneypunct_byname(const string&, size_t refs = 0);
|
|
|
|
| 426 |
protected:
|
| 427 |
~moneypunct_byname();
|
| 428 |
};
|
| 429 |
}
|
| 430 |
```
|
|
|
|
| 3 |
These templates handle monetary formats. A template parameter indicates
|
| 4 |
whether local or international monetary formats are to be used.
|
| 5 |
|
| 6 |
All specifications of member functions for `money_put` and `money_get`
|
| 7 |
in the subclauses of [[category.monetary]] only apply to the
|
| 8 |
+
specializations required in Tables [[tab:locale.category.facets]] and
|
| 9 |
+
[[tab:locale.spec]] [[locale.category]]. Their members use their
|
| 10 |
+
`ios_base&`, `ios_base::iostate&`, and `fill` arguments as described in
|
|
|
|
| 11 |
[[locale.categories]], and the `moneypunct<>` and `ctype<>` facets, to
|
| 12 |
determine formatting details.
|
| 13 |
|
| 14 |
#### Class template `money_get` <a id="locale.money.get">[[locale.money.get]]</a>
|
| 15 |
|
|
|
|
| 41 |
ios_base::iostate& err, string_type& digits) const;
|
| 42 |
};
|
| 43 |
}
|
| 44 |
```
|
| 45 |
|
| 46 |
+
##### Members <a id="locale.money.get.members">[[locale.money.get.members]]</a>
|
| 47 |
|
| 48 |
``` cpp
|
| 49 |
+
iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
|
| 50 |
+
ios_base::iostate& err, long double& quant) const;
|
| 51 |
+
iter_type get(iter_type s, iter_type end, bool intl, ios_base& f,
|
|
|
|
| 52 |
ios_base::iostate& err, string_type& quant) const;
|
| 53 |
```
|
| 54 |
|
| 55 |
*Returns:* `do_get(s, end, intl, f, err, quant)`.
|
| 56 |
|
| 57 |
+
##### Virtual functions <a id="locale.money.get.virtuals">[[locale.money.get.virtuals]]</a>
|
| 58 |
|
| 59 |
``` cpp
|
| 60 |
+
iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
|
| 61 |
+
ios_base::iostate& err, long double& units) const;
|
| 62 |
+
iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str,
|
| 63 |
+
ios_base::iostate& err, string_type& digits) const;
|
|
|
|
|
|
|
| 64 |
```
|
| 65 |
|
| 66 |
*Effects:* Reads characters from `s` to parse and construct a monetary
|
| 67 |
value according to the format specified by a `moneypunct<charT, Intl>`
|
| 68 |
facet reference `mp` and the character mapping specified by a
|
|
|
|
| 72 |
`(err|str.failbit|str.eofbit)` if no more characters are available, and
|
| 73 |
does not change `units` or `digits`. Uses the pattern returned by
|
| 74 |
`mp.neg_format()` to parse all values. The result is returned as an
|
| 75 |
integral value stored in `units` or as a sequence of digits possibly
|
| 76 |
preceded by a minus sign (as produced by `ct.widen(c)` where `c` is
|
| 77 |
+
`’-’` or in the range from `’0’` through `’9’` (inclusive)) stored in
|
| 78 |
`digits`.
|
| 79 |
|
| 80 |
[*Example 1*: The sequence `$1,056.23` in a common United States locale
|
| 81 |
would yield, for `units`, `105623`, or, for `digits`,
|
| 82 |
`"105623"`. — *end example*]
|
|
|
|
| 91 |
element in the format pattern, no white space is consumed. Otherwise,
|
| 92 |
where `money_base::space` appears in any of the initial elements of the
|
| 93 |
format pattern, at least one white space character is required. Where
|
| 94 |
`money_base::none` appears in any of the initial elements of the format
|
| 95 |
pattern, white space is allowed but not required. If
|
| 96 |
+
`(str.flags() & str.showbase)` is `false`, the currency symbol is
|
| 97 |
+
optional and is consumed only if other characters are needed to complete
|
| 98 |
+
the format; otherwise, the currency symbol is required.
|
| 99 |
|
| 100 |
If the first character (if any) in the string `pos` returned by
|
| 101 |
`mp.positive_sign()` or the string `neg` returned by
|
| 102 |
`mp.negative_sign()` is recognized in the position indicated by `sign`
|
| 103 |
in the format pattern, it is consumed and any remaining characters in
|
|
|
|
| 169 |
const string_type& digits) const;
|
| 170 |
};
|
| 171 |
}
|
| 172 |
```
|
| 173 |
|
| 174 |
+
##### Members <a id="locale.money.put.members">[[locale.money.put.members]]</a>
|
| 175 |
|
| 176 |
``` cpp
|
| 177 |
+
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, long double quant) const;
|
| 178 |
+
iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, const string_type& quant) const;
|
|
|
|
|
|
|
| 179 |
```
|
| 180 |
|
| 181 |
*Returns:* `do_put(s, intl, f, loc, quant)`.
|
| 182 |
|
| 183 |
+
##### Virtual functions <a id="locale.money.put.virtuals">[[locale.money.put.virtuals]]</a>
|
| 184 |
|
| 185 |
``` cpp
|
| 186 |
iter_type do_put(iter_type s, bool intl, ios_base& str,
|
| 187 |
char_type fill, long double units) const;
|
| 188 |
iter_type do_put(iter_type s, bool intl, ios_base& str,
|
|
|
|
| 276 |
```
|
| 277 |
|
| 278 |
The `moneypunct<>` facet defines monetary formatting parameters used by
|
| 279 |
`money_get<>` and `money_put<>`. A monetary format is a sequence of four
|
| 280 |
components, specified by a `pattern` value `p`, such that the `part`
|
| 281 |
+
value `static_cast<part>(p.field[i])` determines the `i`ᵗʰ component of
|
| 282 |
the format[^21] In the `field` member of a `pattern` object, each value
|
| 283 |
`symbol`, `sign`, `value`, and either `space` or `none` appears exactly
|
| 284 |
once. The value `none`, if present, is not first; the value `space`, if
|
| 285 |
present, is neither first nor last.
|
| 286 |
|
|
|
|
| 296 |
after all other format components. Where `value` appears, the absolute
|
| 297 |
numeric monetary value is required.
|
| 298 |
|
| 299 |
The format of the numeric monetary value is a decimal number:
|
| 300 |
|
| 301 |
+
``` bnf
|
| 302 |
+
value:
|
| 303 |
+
units fractionalₒₚₜ
|
| 304 |
decimal-point digits
|
| 305 |
```
|
| 306 |
|
| 307 |
+
``` bnf
|
| 308 |
+
fractional:
|
| 309 |
+
decimal-point digitsₒₚₜ
|
| 310 |
+
```
|
| 311 |
+
|
| 312 |
if `frac_digits()` returns a positive value, or
|
| 313 |
|
| 314 |
+
``` bnf
|
| 315 |
+
value:
|
| 316 |
+
units
|
| 317 |
```
|
| 318 |
|
| 319 |
+
otherwise. The symbol indicates the character returned by
|
| 320 |
+
`decimal_point()`. The other symbols are defined as follows:
|
| 321 |
|
| 322 |
+
``` bnf
|
| 323 |
+
units:
|
| 324 |
+
digits
|
| 325 |
+
digits thousands-sep units
|
| 326 |
```
|
| 327 |
|
| 328 |
+
``` bnf
|
| 329 |
+
digits:
|
| 330 |
+
adigit digitsₒₚₜ
|
| 331 |
+
```
|
| 332 |
+
|
| 333 |
+
In the syntax specification, the symbol is any of the values
|
| 334 |
+
`ct.widen(c)` for `c` in the range `'0'` through `'9'` (inclusive) and
|
| 335 |
`ct` is a reference of type `const ctype<charT>&` obtained as described
|
| 336 |
+
in the definitions of `money_get<>` and `money_put<>`. The symbol is the
|
| 337 |
+
character returned by `thousands_sep()`. The space character used is the
|
| 338 |
+
value `ct.widen(' ')`. White space characters are those characters `c`
|
| 339 |
+
for which `ci.is(space, c)` returns `true`. The number of digits
|
| 340 |
+
required after the decimal point (if any) is exactly the value returned
|
| 341 |
+
by `frac_digits()`.
|
| 342 |
|
| 343 |
The placement of thousands-separator characters (if any) is determined
|
| 344 |
by the value returned by `grouping()`, defined identically as the member
|
| 345 |
`numpunct<>::do_grouping()`.
|
| 346 |
|
| 347 |
+
##### Members <a id="locale.moneypunct.members">[[locale.moneypunct.members]]</a>
|
| 348 |
|
| 349 |
``` cpp
|
| 350 |
charT decimal_point() const;
|
| 351 |
charT thousands_sep() const;
|
| 352 |
string grouping() const;
|
|
|
|
| 359 |
```
|
| 360 |
|
| 361 |
Each of these functions `F` returns the result of calling the
|
| 362 |
corresponding virtual member function `do_F()`.
|
| 363 |
|
| 364 |
+
##### Virtual functions <a id="locale.moneypunct.virtuals">[[locale.moneypunct.virtuals]]</a>
|
| 365 |
|
| 366 |
``` cpp
|
| 367 |
charT do_decimal_point() const;
|
| 368 |
```
|
| 369 |
|
|
|
|
| 386 |
|
| 387 |
``` cpp
|
| 388 |
string_type do_curr_symbol() const;
|
| 389 |
```
|
| 390 |
|
| 391 |
+
*Returns:* A string to use as the currency identifier symbol.
|
| 392 |
+
|
| 393 |
+
[*Note 1*: For specializations where the second template parameter is
|
| 394 |
+
`true`, this is typically four characters long: a three-letter code as
|
| 395 |
+
specified by ISO 4217 followed by a space. — *end note*]
|
| 396 |
|
| 397 |
``` cpp
|
| 398 |
string_type do_positive_sign() const;
|
| 399 |
string_type do_negative_sign() const;
|
| 400 |
```
|
| 401 |
|
| 402 |
*Returns:* `do_positive_sign()` returns the string to use to indicate a
|
| 403 |
+
positive monetary value;[^25] `do_negative_sign()` returns the string to
|
| 404 |
use to indicate a negative value.
|
| 405 |
|
| 406 |
``` cpp
|
| 407 |
int do_frac_digits() const;
|
| 408 |
```
|
| 409 |
|
| 410 |
*Returns:* The number of digits after the decimal radix separator, if
|
| 411 |
+
any.[^26]
|
| 412 |
|
| 413 |
``` cpp
|
| 414 |
pattern do_pos_format() const;
|
| 415 |
pattern do_neg_format() const;
|
| 416 |
```
|
| 417 |
|
| 418 |
*Returns:* The specializations required in
|
| 419 |
+
[[locale.spec]][[locale.category]], namely
|
| 420 |
+
|
| 421 |
+
- `moneypunct<char>`,
|
| 422 |
+
- `moneypunct<wchar_t>`,
|
| 423 |
+
- `moneypunct<char, true>`, and
|
| 424 |
+
- `moneypunct<wchar_t, true>`,
|
| 425 |
+
|
| 426 |
+
return an object of type `pattern` initialized to
|
| 427 |
+
`{ symbol, sign, none, value }`.[^27]
|
| 428 |
|
| 429 |
#### Class template `moneypunct_byname` <a id="locale.moneypunct.byname">[[locale.moneypunct.byname]]</a>
|
| 430 |
|
| 431 |
``` cpp
|
| 432 |
namespace std {
|
|
|
|
| 436 |
using pattern = money_base::pattern;
|
| 437 |
using string_type = basic_string<charT>;
|
| 438 |
|
| 439 |
explicit moneypunct_byname(const char*, size_t refs = 0);
|
| 440 |
explicit moneypunct_byname(const string&, size_t refs = 0);
|
| 441 |
+
|
| 442 |
protected:
|
| 443 |
~moneypunct_byname();
|
| 444 |
};
|
| 445 |
}
|
| 446 |
```
|