- tmp/tmp3gxeplhc/{from.md → to.md} +167 -219
tmp/tmp3gxeplhc/{from.md → to.md}
RENAMED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
## Standard `locale` categories <a id="locale.categories">[[locale.categories]]</a>
|
| 2 |
|
|
|
|
|
|
|
| 3 |
Each of the standard categories includes a family of facets. Some of
|
| 4 |
these implement formatting or parsing of a datum, for use by standard or
|
| 5 |
users’ iostream operators `<<` and `>>`, as members `put()` and `get()`,
|
| 6 |
respectively. Each such member function takes an `ios_base&` argument
|
| 7 |
whose members `flags()`, `precision()`, and `width()`, specify the
|
|
@@ -14,15 +16,17 @@ The `put()` members make no provision for error reporting. (Any failures
|
|
| 14 |
of the OutputIterator argument can be extracted from the returned
|
| 15 |
iterator.) The `get()` members take an `ios_base::iostate&` argument
|
| 16 |
whose value they ignore, but set to `ios_base::failbit` in case of a
|
| 17 |
parse error.
|
| 18 |
|
| 19 |
-
Within
|
| 20 |
-
another virtual function.
|
| 21 |
|
| 22 |
### The `ctype` category <a id="category.ctype">[[category.ctype]]</a>
|
| 23 |
|
|
|
|
|
|
|
| 24 |
``` cpp
|
| 25 |
namespace std {
|
| 26 |
class ctype_base {
|
| 27 |
public:
|
| 28 |
using mask = see below;
|
|
@@ -46,10 +50,12 @@ namespace std {
|
|
| 46 |
|
| 47 |
The type `mask` is a bitmask type [[bitmask.types]].
|
| 48 |
|
| 49 |
#### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
|
| 50 |
|
|
|
|
|
|
|
| 51 |
``` cpp
|
| 52 |
namespace std {
|
| 53 |
template<class charT>
|
| 54 |
class ctype : public locale::facet, public ctype_base {
|
| 55 |
public:
|
|
@@ -219,12 +225,14 @@ charT do_widen(char c) const;
|
|
| 219 |
const char* do_widen(const char* low, const char* high, charT* dest) const;
|
| 220 |
```
|
| 221 |
|
| 222 |
*Effects:* Applies the simplest reasonable transformation from a `char`
|
| 223 |
value or sequence of `char` values to the corresponding `charT` value or
|
| 224 |
-
values.[^5]
|
| 225 |
-
|
|
|
|
|
|
|
| 226 |
|
| 227 |
For any named `ctype` category with a `ctype<charT>` facet `ctc` and
|
| 228 |
valid `ctype_base::mask` value `M`,
|
| 229 |
`(ctc.is(M, c) || !is(M, do_widen(c)) )` is `true`.[^6]
|
| 230 |
|
|
@@ -241,12 +249,12 @@ const charT* do_narrow(const charT* low, const charT* high, char dfault, char* d
|
|
| 241 |
|
| 242 |
*Effects:* Applies the simplest reasonable transformation from a `charT`
|
| 243 |
value or sequence of `charT` values to the corresponding `char` value or
|
| 244 |
values.
|
| 245 |
|
| 246 |
-
For any character `c` in the basic
|
| 247 |
-
|
| 248 |
|
| 249 |
``` cpp
|
| 250 |
do_widen(do_narrow(c, 0)) == c
|
| 251 |
```
|
| 252 |
|
|
@@ -284,10 +292,12 @@ namespace std {
|
|
| 284 |
}
|
| 285 |
```
|
| 286 |
|
| 287 |
#### `ctype<char>` specialization <a id="facet.ctype.special">[[facet.ctype.special]]</a>
|
| 288 |
|
|
|
|
|
|
|
| 289 |
``` cpp
|
| 290 |
namespace std {
|
| 291 |
template<>
|
| 292 |
class ctype<char> : public locale::facet, public ctype_base {
|
| 293 |
public:
|
|
@@ -331,12 +341,14 @@ namespace std {
|
|
| 331 |
};
|
| 332 |
}
|
| 333 |
```
|
| 334 |
|
| 335 |
A specialization `ctype<char>` is provided so that the member functions
|
| 336 |
-
on type `char` can be implemented inline.[^7]
|
| 337 |
-
|
|
|
|
|
|
|
| 338 |
|
| 339 |
##### Destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
|
| 340 |
|
| 341 |
``` cpp
|
| 342 |
~ctype();
|
|
@@ -460,10 +472,12 @@ virtual const char* do_narrow(const char* low, const char* high,
|
|
| 460 |
These functions are described identically as those members of the same
|
| 461 |
name in the `ctype` class template [[locale.ctype.members]].
|
| 462 |
|
| 463 |
#### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
|
| 464 |
|
|
|
|
|
|
|
| 465 |
``` cpp
|
| 466 |
namespace std {
|
| 467 |
class codecvt_base {
|
| 468 |
public:
|
| 469 |
enum result { ok, partial, error, noconv };
|
|
@@ -532,19 +546,19 @@ mapped between.
|
|
| 532 |
The specializations required in [[locale.category.facets]]
|
| 533 |
[[locale.category]] convert the implementation-defined native character
|
| 534 |
set. `codecvt<char, char, mbstate_t>` implements a degenerate
|
| 535 |
conversion; it does not convert at all. The specialization
|
| 536 |
`codecvt<char16_t, char8_t, mbstate_t>` converts between the UTF-16 and
|
| 537 |
-
UTF-8 encoding forms, and the specialization
|
| 538 |
-
`<char32_t, char8_t, mbstate_t>` converts between the UTF-32 and
|
| 539 |
-
encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts
|
| 540 |
-
native character sets for ordinary and wide characters.
|
| 541 |
-
on `mbstate_t` perform conversion between encodings
|
| 542 |
-
implementer. Other encodings can be converted by
|
| 543 |
-
program-defined `stateT` type. Objects of type
|
| 544 |
-
state that is useful to communicate to or from
|
| 545 |
-
or `do_out` members.
|
| 546 |
|
| 547 |
##### Members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
|
| 548 |
|
| 549 |
``` cpp
|
| 550 |
result out(
|
|
@@ -657,44 +671,45 @@ shall also return `ok`.[^8]
|
|
| 657 |
|
| 658 |
[*Note 1*: As a result of operations on `state`, it can return `ok` or
|
| 659 |
`partial` and set `from_next == from` and
|
| 660 |
`to_next != to`. — *end note*]
|
| 661 |
|
| 662 |
-
*Remarks:* Its operations on `state` are unspecified.
|
| 663 |
-
|
| 664 |
-
[*Note 2*: This argument can be used, for example, to maintain shift
|
| 665 |
-
state, to specify conversion options (such as count only), or to
|
| 666 |
-
identify a cache of seek offsets. — *end note*]
|
| 667 |
-
|
| 668 |
*Returns:* An enumeration value, as summarized in
|
| 669 |
[[locale.codecvt.inout]].
|
| 670 |
|
| 671 |
**Table: `do_in/do_out` result values** <a id="locale.codecvt.inout">[locale.codecvt.inout]</a>
|
| 672 |
|
| 673 |
| Value | Meaning |
|
| 674 |
| --------- | ------------------------------------------------------------------------------------------------ |
|
| 675 |
| `ok` | completed the conversion |
|
| 676 |
| `partial` | not all source characters converted |
|
| 677 |
-
| `error` | encountered a character in {[}`from`, `from_end`{)} that
|
| 678 |
| `noconv` | `internT` and `externT` are the same type, and input sequence is identical to converted sequence |
|
| 679 |
|
| 680 |
|
| 681 |
A return value of `partial`, if `(from_next == from_end)`, indicates
|
| 682 |
that either the destination sequence has not absorbed all the available
|
| 683 |
destination elements, or that additional source elements are needed
|
| 684 |
before another destination element can be produced.
|
| 685 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 686 |
``` cpp
|
| 687 |
result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
|
| 688 |
```
|
| 689 |
|
| 690 |
*Preconditions:* `(to <= to_end)` is well-defined and `true`; `state` is
|
| 691 |
initialized, if at the beginning of a sequence, or else is equal to the
|
| 692 |
result of converting the preceding characters in the sequence.
|
| 693 |
|
| 694 |
*Effects:* Places characters starting at `to` that should be appended to
|
| 695 |
terminate a sequence when the current `stateT` is given by `state`.[^9]
|
|
|
|
| 696 |
Stores no more than `(to_end - to)` destination elements, and leaves the
|
| 697 |
`to_next` pointer pointing one beyond the last element successfully
|
| 698 |
stored.
|
| 699 |
|
| 700 |
*Returns:* An enumeration value, as summarized in
|
|
@@ -770,10 +785,12 @@ namespace std {
|
|
| 770 |
}
|
| 771 |
```
|
| 772 |
|
| 773 |
### The numeric category <a id="category.numeric">[[category.numeric]]</a>
|
| 774 |
|
|
|
|
|
|
|
| 775 |
The classes `num_get<>` and `num_put<>` handle numeric formatting and
|
| 776 |
parsing. Virtual functions are provided for several numeric types.
|
| 777 |
Implementations may (but are not required to) delegate extraction of
|
| 778 |
smaller types to extractors for larger types.[^11]
|
| 779 |
|
|
@@ -788,14 +805,16 @@ specifications [[locale.categories]], and to its imbued locale for the
|
|
| 788 |
`numpunct<>` facet to identify all numeric punctuation preferences, and
|
| 789 |
also for the `ctype<>` facet to perform character classification.
|
| 790 |
|
| 791 |
Extractor and inserter members of the standard iostreams use `num_get<>`
|
| 792 |
and `num_put<>` member functions for formatting and parsing numeric
|
| 793 |
-
values
|
| 794 |
|
| 795 |
#### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
|
| 796 |
|
|
|
|
|
|
|
| 797 |
``` cpp
|
| 798 |
namespace std {
|
| 799 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 800 |
class num_get : public locale::facet {
|
| 801 |
public:
|
|
@@ -926,129 +945,27 @@ The details of this operation occur in three stages
|
|
| 926 |
determined in stage 1.
|
| 927 |
- Stage 3: Store results
|
| 928 |
|
| 929 |
The details of the stages are presented below.
|
| 930 |
|
| 931 |
-
|
| 932 |
|
| 933 |
-
|
| 934 |
|
| 935 |
-
```
|
| 936 |
-
|
| 937 |
-
|
| 938 |
-
|
| 939 |
-
|
| 940 |
-
``
|
| 941 |
|
| 942 |
-
|
| 943 |
-
conversion specifier as indicated in [[facet.num.get.int]]. The
|
| 944 |
-
table is ordered. That is, the first line whose condition is true
|
| 945 |
-
applies.
|
| 946 |
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
| State | `stdio` equivalent |
|
| 950 |
-
| ------------------------ | ------------------ |
|
| 951 |
-
| `basefield == oct` | `%o` |
|
| 952 |
-
| `basefield == hex` | `%X` |
|
| 953 |
-
| `basefield == 0` | `%i` `signed` integral type | `%d` |
|
| 954 |
-
| `unsigned` integral type | `%u` |
|
| 955 |
-
|
| 956 |
-
|
| 957 |
-
For conversions to a floating-point type the specifier is `%g`.
|
| 958 |
-
|
| 959 |
-
For conversions to `void*` the specifier is `%p`.
|
| 960 |
-
|
| 961 |
-
A length modifier is added to the conversion specification, if needed,
|
| 962 |
-
as indicated in [[facet.num.get.length]].
|
| 963 |
-
|
| 964 |
-
**Table: Length modifier** <a id="facet.num.get.length">[facet.num.get.length]</a>
|
| 965 |
-
|
| 966 |
-
| Type | Length modifier |
|
| 967 |
-
| -------------------- | --------------- |
|
| 968 |
-
| `short` | `h` |
|
| 969 |
-
| `unsigned short` | `h` |
|
| 970 |
-
| `long` | `l` |
|
| 971 |
-
| `unsigned long` | `l` |
|
| 972 |
-
| `long long` | `ll` |
|
| 973 |
-
| `unsigned long long` | `ll` |
|
| 974 |
-
| `double` | `l` |
|
| 975 |
-
| `long double` | `L` |
|
| 976 |
-
|
| 977 |
-
- **Stage 2:**
|
| 978 |
-
|
| 979 |
-
If `in == end` then stage 2 terminates. Otherwise a `charT` is taken
|
| 980 |
-
from `in` and local variables are initialized as if by
|
| 981 |
-
|
| 982 |
-
``` cpp
|
| 983 |
-
char_type ct = *in;
|
| 984 |
-
char c = src[find(atoms, atoms + sizeof(src) - 1, ct) - atoms];
|
| 985 |
-
if (ct == use_facet<numpunct<charT>>(loc).decimal_point())
|
| 986 |
-
c = '.';
|
| 987 |
-
bool discard =
|
| 988 |
-
ct == use_facet<numpunct<charT>>(loc).thousands_sep()
|
| 989 |
-
&& use_facet<numpunct<charT>>(loc).grouping().length() != 0;
|
| 990 |
-
```
|
| 991 |
-
|
| 992 |
-
where the values `src` and `atoms` are defined as if by:
|
| 993 |
-
|
| 994 |
-
``` cpp
|
| 995 |
-
static const char src[] = "0123456789abcdefxABCDEFX+-";
|
| 996 |
-
char_type atoms[sizeof(src)];
|
| 997 |
-
use_facet<ctype<charT>>(loc).widen(src, src + sizeof(src), atoms);
|
| 998 |
-
```
|
| 999 |
-
|
| 1000 |
-
for this value of `loc`.
|
| 1001 |
-
|
| 1002 |
-
If `discard` is `true`, then if `’.’` has not yet been accumulated, then
|
| 1003 |
-
the position of the character is remembered, but the character is
|
| 1004 |
-
otherwise ignored. Otherwise, if `’.’` has already been accumulated, the
|
| 1005 |
-
character is discarded and Stage 2 terminates. If it is not discarded,
|
| 1006 |
-
then a check is made to determine if `c` is allowed as the next
|
| 1007 |
-
character of an input field of the conversion specifier returned by
|
| 1008 |
-
Stage 1. If so, it is accumulated.
|
| 1009 |
-
|
| 1010 |
-
If the character is either discarded or accumulated then `in` is
|
| 1011 |
-
advanced by `++in` and processing returns to the beginning of stage 2.
|
| 1012 |
-
|
| 1013 |
-
- **Stage 3:**
|
| 1014 |
-
|
| 1015 |
-
The sequence of `char`s accumulated in stage 2 (the field) is converted
|
| 1016 |
-
to a numeric value by the rules of one of the functions declared in the
|
| 1017 |
-
header `<cstdlib>`:
|
| 1018 |
-
|
| 1019 |
-
- For a signed integer value, the function `strtoll`.
|
| 1020 |
-
|
| 1021 |
-
- For an unsigned integer value, the function `strtoull`.
|
| 1022 |
-
|
| 1023 |
-
- For a `float` value, the function `strtof`.
|
| 1024 |
-
|
| 1025 |
-
- For a `double` value, the function `strtod`.
|
| 1026 |
-
|
| 1027 |
-
- For a `long double` value, the function `strtold`.
|
| 1028 |
-
|
| 1029 |
-
The numeric value to be stored can be one of:
|
| 1030 |
-
|
| 1031 |
-
- zero, if the conversion function does not convert the entire field.
|
| 1032 |
-
|
| 1033 |
-
- the most positive (or negative) representable value, if the field to
|
| 1034 |
-
be converted to a signed integer type represents a value too large
|
| 1035 |
-
positive (or negative) to be represented in `val`.
|
| 1036 |
-
|
| 1037 |
-
- the most positive representable value, if the field to be converted to
|
| 1038 |
-
an unsigned integer type represents a value that cannot be represented
|
| 1039 |
-
in `val`.
|
| 1040 |
-
|
| 1041 |
-
- the converted value, otherwise.
|
| 1042 |
-
|
| 1043 |
-
The resultant numeric value is stored in `val`. If the conversion
|
| 1044 |
-
function does not convert the entire field, or if the field represents a
|
| 1045 |
-
value outside the range of representable values, `ios_base::failbit` is
|
| 1046 |
-
assigned to `err`.
|
| 1047 |
|
| 1048 |
Digit grouping is checked. That is, the positions of discarded
|
| 1049 |
-
separators
|
| 1050 |
`use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
|
| 1051 |
then `ios_base::failbit` is assigned to `err`.
|
| 1052 |
|
| 1053 |
In any case, if stage 2 processing was terminated by the test for
|
| 1054 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
|
@@ -1081,11 +998,11 @@ character successfully matched. If `val` is set, then `err` is set to
|
|
| 1081 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 1082 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 1083 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 1084 |
for the failure was that `(in == end)`.
|
| 1085 |
|
| 1086 |
-
[*Example
|
| 1087 |
sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
|
| 1088 |
sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
|
| 1089 |
`’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
|
| 1090 |
sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
|
| 1091 |
targets `("")`, any input sequence yields
|
|
@@ -1093,10 +1010,12 @@ targets `("")`, any input sequence yields
|
|
| 1093 |
|
| 1094 |
*Returns:* `in`.
|
| 1095 |
|
| 1096 |
#### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
|
| 1097 |
|
|
|
|
|
|
|
| 1098 |
``` cpp
|
| 1099 |
namespace std {
|
| 1100 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
| 1101 |
class num_put : public locale::facet {
|
| 1102 |
public:
|
|
@@ -1296,24 +1215,25 @@ const numpunct<charT>& punct = use_facet<numpunct<charT>>(loc);
|
|
| 1296 |
```
|
| 1297 |
|
| 1298 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 1299 |
into the sequence as determined by the value returned by
|
| 1300 |
`punct.do_grouping()` using the method described
|
| 1301 |
-
in [[facet.numpunct.virtuals]]
|
| 1302 |
|
| 1303 |
-
Decimal point characters(.) are replaced by `punct.decimal_point()`
|
| 1304 |
|
| 1305 |
- **Stage 3:**
|
| 1306 |
|
| 1307 |
A local variable is initialized as
|
| 1308 |
|
| 1309 |
``` cpp
|
| 1310 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 1311 |
```
|
| 1312 |
|
| 1313 |
-
The location of any padding[^12]
|
| 1314 |
-
|
|
|
|
| 1315 |
|
| 1316 |
**Table: Fill padding** <a id="facet.num.put.fill">[facet.num.put.fill]</a>
|
| 1317 |
|
| 1318 |
| State | Location |
|
| 1319 |
| ------------------------------------------------------------------------------ | ------------------ |
|
|
@@ -1358,10 +1278,12 @@ and returns `out`.
|
|
| 1358 |
|
| 1359 |
### The numeric punctuation facet <a id="facet.numpunct">[[facet.numpunct]]</a>
|
| 1360 |
|
| 1361 |
#### Class template `numpunct` <a id="locale.numpunct">[[locale.numpunct]]</a>
|
| 1362 |
|
|
|
|
|
|
|
| 1363 |
``` cpp
|
| 1364 |
namespace std {
|
| 1365 |
template<class charT>
|
| 1366 |
class numpunct : public locale::facet {
|
| 1367 |
public:
|
|
@@ -1387,14 +1309,12 @@ namespace std {
|
|
| 1387 |
virtual string_type do_falsename() const; // for bool
|
| 1388 |
};
|
| 1389 |
}
|
| 1390 |
```
|
| 1391 |
|
| 1392 |
-
`numpunct<>`
|
| 1393 |
-
|
| 1394 |
-
specifies numeric punctuation. The specializations required in
|
| 1395 |
-
[[locale.category.facets]] [[locale.category]], namely
|
| 1396 |
`numpunct<{}wchar_t>` and `numpunct<char>`, provide classic `"C"`
|
| 1397 |
numeric formats, i.e., they contain information equivalent to that
|
| 1398 |
contained in the `"C"` locale or their wide character counterparts as if
|
| 1399 |
obtained by a call to `widen`.
|
| 1400 |
|
|
@@ -1499,14 +1419,15 @@ required specializations return `’,’` or `L’,’`.
|
|
| 1499 |
``` cpp
|
| 1500 |
string do_grouping() const;
|
| 1501 |
```
|
| 1502 |
|
| 1503 |
*Returns:* A `string` `vec` used as a vector of integer values, in which
|
| 1504 |
-
each element `vec[i]` represents the number of digits[^13]
|
| 1505 |
-
|
| 1506 |
-
|
| 1507 |
-
|
|
|
|
| 1508 |
group is unlimited.
|
| 1509 |
|
| 1510 |
The required specializations return the empty string, indicating no
|
| 1511 |
grouping.
|
| 1512 |
|
|
@@ -1543,10 +1464,12 @@ namespace std {
|
|
| 1543 |
|
| 1544 |
### The collate category <a id="category.collate">[[category.collate]]</a>
|
| 1545 |
|
| 1546 |
#### Class template `collate` <a id="locale.collate">[[locale.collate]]</a>
|
| 1547 |
|
|
|
|
|
|
|
| 1548 |
``` cpp
|
| 1549 |
namespace std {
|
| 1550 |
template<class charT>
|
| 1551 |
class collate : public locale::facet {
|
| 1552 |
public:
|
|
@@ -1576,11 +1499,11 @@ The class `collate<charT>` provides features for use in the collation
|
|
| 1576 |
(comparison) and hashing of strings. A locale member function template,
|
| 1577 |
`operator()`, uses the collate facet to allow a locale to act directly
|
| 1578 |
as the predicate argument for standard algorithms [[algorithms]] and
|
| 1579 |
containers operating on strings. The specializations required in
|
| 1580 |
[[locale.category.facets]] [[locale.category]], namely `collate<char>`
|
| 1581 |
-
and `collate<wchar_t>`, apply
|
| 1582 |
[[alg.lex.comparison]].
|
| 1583 |
|
| 1584 |
Each function compares a string of characters `*p` in the range \[`low`,
|
| 1585 |
`high`).
|
| 1586 |
|
|
@@ -1633,13 +1556,13 @@ long do_hash(const charT* low, const charT* high) const;
|
|
| 1633 |
|
| 1634 |
*Returns:* An integer value equal to the result of calling `hash()` on
|
| 1635 |
any other string for which `do_compare()` returns 0 (equal) when passed
|
| 1636 |
the two strings.
|
| 1637 |
|
| 1638 |
-
|
| 1639 |
-
string which does not compare equal should be very small,
|
| 1640 |
-
`(1.0/numeric_limits<unsigned long>::max())`.
|
| 1641 |
|
| 1642 |
#### Class template `collate_byname` <a id="locale.collate.byname">[[locale.collate.byname]]</a>
|
| 1643 |
|
| 1644 |
``` cpp
|
| 1645 |
namespace std {
|
|
@@ -1657,10 +1580,12 @@ namespace std {
|
|
| 1657 |
}
|
| 1658 |
```
|
| 1659 |
|
| 1660 |
### The time category <a id="category.time">[[category.time]]</a>
|
| 1661 |
|
|
|
|
|
|
|
| 1662 |
Templates `time_get<charT, InputIterator>` and
|
| 1663 |
`time_put<charT, OutputIterator>` provide date and time formatting and
|
| 1664 |
parsing. All specifications of member functions for `time_put` and
|
| 1665 |
`time_get` in the subclauses of [[category.time]] only apply to the
|
| 1666 |
specializations required in Tables [[tab:locale.category.facets]] and
|
|
@@ -1669,10 +1594,12 @@ specializations required in Tables [[tab:locale.category.facets]] and
|
|
| 1669 |
[[locale.categories]], and the `ctype<>` facet, to determine formatting
|
| 1670 |
details.
|
| 1671 |
|
| 1672 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 1673 |
|
|
|
|
|
|
|
| 1674 |
``` cpp
|
| 1675 |
namespace std {
|
| 1676 |
class time_base {
|
| 1677 |
public:
|
| 1678 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
@@ -1722,19 +1649,17 @@ namespace std {
|
|
| 1722 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 1723 |
};
|
| 1724 |
}
|
| 1725 |
```
|
| 1726 |
|
| 1727 |
-
`time_get`
|
| 1728 |
-
|
| 1729 |
-
|
| 1730 |
-
or date into a `struct tm` object. Each `get` member parses a format as
|
| 1731 |
-
produced by a corresponding format specifier to `time_put<>::put`. If
|
| 1732 |
the sequence being parsed matches the correct format, the corresponding
|
| 1733 |
-
members of the `
|
| 1734 |
-
|
| 1735 |
-
|
| 1736 |
|
| 1737 |
If the end iterator is reached during parsing by any of the `get()`
|
| 1738 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 1739 |
|
| 1740 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
@@ -1800,12 +1725,12 @@ the first of the following conditions holds:
|
|
| 1800 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 1801 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 1802 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 1803 |
modifier character, followed by a conversion specifier character,
|
| 1804 |
`format`, together forming a conversion specification valid for the
|
| 1805 |
-
|
| 1806 |
-
|
| 1807 |
whether the conversion specification is complete and valid, the
|
| 1808 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 1809 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 1810 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 1811 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
@@ -1836,37 +1761,38 @@ so. — *end note*]
|
|
| 1836 |
dateorder do_date_order() const;
|
| 1837 |
```
|
| 1838 |
|
| 1839 |
*Returns:* An enumeration value indicating the preferred order of
|
| 1840 |
components for those date formats that are composed of day, month, and
|
| 1841 |
-
year.[^16]
|
| 1842 |
-
|
| 1843 |
-
|
|
|
|
| 1844 |
|
| 1845 |
``` cpp
|
| 1846 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 1847 |
ios_base::iostate& err, tm* t) const;
|
| 1848 |
```
|
| 1849 |
|
| 1850 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 1851 |
-
`
|
| 1852 |
-
|
| 1853 |
-
|
| 1854 |
|
| 1855 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1856 |
recognized as possibly part of a valid time.
|
| 1857 |
|
| 1858 |
``` cpp
|
| 1859 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 1860 |
ios_base::iostate& err, tm* t) const;
|
| 1861 |
```
|
| 1862 |
|
| 1863 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 1864 |
-
`
|
| 1865 |
-
|
| 1866 |
-
|
| 1867 |
-
|
| 1868 |
|
| 1869 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 1870 |
|
| 1871 |
| `date_order()` | Format |
|
| 1872 |
| -------------- | ---------- |
|
|
@@ -1890,13 +1816,13 @@ iter_type do_get_monthname(iter_type s, iter_type end, ios_base& str,
|
|
| 1890 |
ios_base::iostate& err, tm* t) const;
|
| 1891 |
```
|
| 1892 |
|
| 1893 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 1894 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 1895 |
-
abbreviation that is followed by characters that
|
| 1896 |
-
|
| 1897 |
-
|
| 1898 |
|
| 1899 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1900 |
recognized as part of a valid name.
|
| 1901 |
|
| 1902 |
``` cpp
|
|
@@ -1919,36 +1845,36 @@ iter_type do_get(iter_type s, iter_type end, ios_base& f,
|
|
| 1919 |
|
| 1920 |
*Preconditions:* `t` points to an object.
|
| 1921 |
|
| 1922 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 1923 |
It then reads characters starting at `s` until it encounters an error,
|
| 1924 |
-
or until it has extracted and assigned those `
|
| 1925 |
-
|
| 1926 |
-
appropriate for the
|
| 1927 |
-
|
| 1928 |
-
|
| 1929 |
-
|
| 1930 |
-
|
| 1931 |
-
|
| 1932 |
`err |= ios_base::eofbit`.
|
| 1933 |
|
| 1934 |
-
For complex conversion
|
| 1935 |
-
|
| 1936 |
-
function is unable to unambiguously determine some or all
|
| 1937 |
-
members from the input sequence \[`s`, `end`), it evaluates
|
| 1938 |
-
`err |= ios_base::eofbit`. In such cases the values of those `
|
| 1939 |
members are unspecified and may be outside their valid range.
|
| 1940 |
|
| 1941 |
-
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 1942 |
-
the address of the same `struct tm` object will update the current
|
| 1943 |
-
contents of the object or simply overwrite its members. Portable
|
| 1944 |
-
programs should zero out the object before invoking the function.
|
| 1945 |
-
|
| 1946 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1947 |
recognized as possibly part of a valid input sequence for the given
|
| 1948 |
`format` and `modifier`.
|
| 1949 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1950 |
#### Class template `time_get_byname` <a id="locale.time.get.byname">[[locale.time.get.byname]]</a>
|
| 1951 |
|
| 1952 |
``` cpp
|
| 1953 |
namespace std {
|
| 1954 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
|
@@ -2011,18 +1937,20 @@ call to `do_put`; thus, format elements and other characters are
|
|
| 2011 |
interleaved in the output in the order in which they appear in the
|
| 2012 |
pattern. Format sequences are identified by converting each character
|
| 2013 |
`c` to a `char` value as if by `ct.narrow(c, 0)`, where `ct` is a
|
| 2014 |
reference to `ctype<charT>` obtained from `str.getloc()`. The first
|
| 2015 |
character of each sequence is equal to `’%’`, followed by an optional
|
| 2016 |
-
modifier character `mod`[^17]
|
| 2017 |
-
|
| 2018 |
-
|
|
|
|
|
|
|
| 2019 |
`do_put(s, str, fill, t, spec, mod)`.
|
| 2020 |
|
| 2021 |
The second form calls `do_put(s, str, fill, t, format, modifier)`.
|
| 2022 |
|
| 2023 |
-
[*Note 1*: The `fill` argument
|
| 2024 |
implementation-defined formats or by derivations. A space character is a
|
| 2025 |
reasonable default for this argument. — *end note*]
|
| 2026 |
|
| 2027 |
*Returns:* An iterator pointing immediately after the last character
|
| 2028 |
produced.
|
|
@@ -2036,21 +1964,29 @@ iter_type do_put(iter_type s, ios_base&, char_type fill, const tm* t,
|
|
| 2036 |
|
| 2037 |
*Effects:* Formats the contents of the parameter `t` into characters
|
| 2038 |
placed on the output sequence `s`. Formatting is controlled by the
|
| 2039 |
parameters `format` and `modifier`, interpreted identically as the
|
| 2040 |
format specifiers in the string argument to the standard library
|
| 2041 |
-
function `strftime()`
|
| 2042 |
-
|
| 2043 |
-
|
|
|
|
|
|
|
|
|
|
| 2044 |
|
| 2045 |
*Returns:* An iterator pointing immediately after the last character
|
| 2046 |
produced.
|
| 2047 |
|
| 2048 |
-
[*Note
|
| 2049 |
implementation-defined formats or by derivations. A space character is a
|
| 2050 |
reasonable default for this argument. — *end note*]
|
| 2051 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2052 |
#### Class template `time_put_byname` <a id="locale.time.put.byname">[[locale.time.put.byname]]</a>
|
| 2053 |
|
| 2054 |
``` cpp
|
| 2055 |
namespace std {
|
| 2056 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
|
@@ -2068,10 +2004,12 @@ namespace std {
|
|
| 2068 |
}
|
| 2069 |
```
|
| 2070 |
|
| 2071 |
### The monetary category <a id="category.monetary">[[category.monetary]]</a>
|
| 2072 |
|
|
|
|
|
|
|
| 2073 |
These templates handle monetary formats. A template parameter indicates
|
| 2074 |
whether local or international monetary formats are to be used.
|
| 2075 |
|
| 2076 |
All specifications of member functions for `money_put` and `money_get`
|
| 2077 |
in the subclauses of [[category.monetary]] only apply to the
|
|
@@ -2188,11 +2126,11 @@ the result is given a positive sign.
|
|
| 2188 |
|
| 2189 |
Digits in the numeric monetary component are extracted and placed in
|
| 2190 |
`digits`, or into a character buffer `buf1` for conversion to produce a
|
| 2191 |
value for `units`, in the order in which they appear, preceded by a
|
| 2192 |
minus sign if and only if the result is negative. The value `units` is
|
| 2193 |
-
produced as if by[^
|
| 2194 |
|
| 2195 |
``` cpp
|
| 2196 |
for (int i = 0; i < n; ++i)
|
| 2197 |
buf2[i] = src[find(atoms, atoms+sizeof(src), buf1[i]) - atoms];
|
| 2198 |
buf2[n] = 0;
|
|
@@ -2279,10 +2217,13 @@ minus sign) in `digits` or `buf2`. In `digits`, only the optional
|
|
| 2279 |
leading minus sign and the immediately subsequent digit characters (as
|
| 2280 |
classified according to `ct`) are used; any trailing characters
|
| 2281 |
(including digits appearing after a non-digit character) are ignored.
|
| 2282 |
Calls `str.width(0)`.
|
| 2283 |
|
|
|
|
|
|
|
|
|
|
| 2284 |
*Remarks:* The currency symbol is generated if and only if
|
| 2285 |
`(str.flags() & str.showbase)` is nonzero. If the number of characters
|
| 2286 |
generated for the specified format is less than the value returned by
|
| 2287 |
`str.width()` on entry to the function, then copies of `fill` are
|
| 2288 |
inserted as necessary to pad to the specified width. For the value `af`
|
|
@@ -2294,15 +2235,14 @@ before the other characters.
|
|
| 2294 |
|
| 2295 |
[*Note 1*: It is possible, with some combinations of format patterns
|
| 2296 |
and flag values, to produce output that cannot be parsed using
|
| 2297 |
`num_get<>::get`. — *end note*]
|
| 2298 |
|
| 2299 |
-
*Returns:* An iterator pointing immediately after the last character
|
| 2300 |
-
produced.
|
| 2301 |
-
|
| 2302 |
#### Class template `moneypunct` <a id="locale.moneypunct">[[locale.moneypunct]]</a>
|
| 2303 |
|
|
|
|
|
|
|
| 2304 |
``` cpp
|
| 2305 |
namespace std {
|
| 2306 |
class money_base {
|
| 2307 |
public:
|
| 2308 |
enum part { none, space, symbol, sign, value };
|
|
@@ -2347,14 +2287,16 @@ namespace std {
|
|
| 2347 |
|
| 2348 |
The `moneypunct<>` facet defines monetary formatting parameters used by
|
| 2349 |
`money_get<>` and `money_put<>`. A monetary format is a sequence of four
|
| 2350 |
components, specified by a `pattern` value `p`, such that the `part`
|
| 2351 |
value `static_cast<part>(p.field[i])` determines the `i`ᵗʰ component of
|
| 2352 |
-
the format[^
|
| 2353 |
-
|
| 2354 |
-
|
| 2355 |
-
|
|
|
|
|
|
|
| 2356 |
|
| 2357 |
Where `none` or `space` appears, whitespace is permitted in the format,
|
| 2358 |
except where `none` appears at the end, in which case no whitespace is
|
| 2359 |
permitted. The value `space` indicates that at least one space is
|
| 2360 |
required at that position. Where `symbol` appears, the sequence of
|
|
@@ -2436,25 +2378,25 @@ corresponding virtual member function `do_F()`.
|
|
| 2436 |
``` cpp
|
| 2437 |
charT do_decimal_point() const;
|
| 2438 |
```
|
| 2439 |
|
| 2440 |
*Returns:* The radix separator to use in case `do_frac_digits()` is
|
| 2441 |
-
greater than zero.[^
|
| 2442 |
|
| 2443 |
``` cpp
|
| 2444 |
charT do_thousands_sep() const;
|
| 2445 |
```
|
| 2446 |
|
| 2447 |
*Returns:* The digit group separator to use in case `do_grouping()`
|
| 2448 |
-
specifies a digit grouping pattern.[^
|
| 2449 |
|
| 2450 |
``` cpp
|
| 2451 |
string do_grouping() const;
|
| 2452 |
```
|
| 2453 |
|
| 2454 |
*Returns:* A pattern defined identically as, but not necessarily equal
|
| 2455 |
-
to, the result of `numpunct<charT>::do_grouping()`.[^
|
| 2456 |
|
| 2457 |
``` cpp
|
| 2458 |
string_type do_curr_symbol() const;
|
| 2459 |
```
|
| 2460 |
|
|
@@ -2468,19 +2410,21 @@ specified by ISO 4217 followed by a space. — *end note*]
|
|
| 2468 |
string_type do_positive_sign() const;
|
| 2469 |
string_type do_negative_sign() const;
|
| 2470 |
```
|
| 2471 |
|
| 2472 |
*Returns:* `do_positive_sign()` returns the string to use to indicate a
|
| 2473 |
-
positive monetary value;[^
|
| 2474 |
-
|
|
|
|
|
|
|
| 2475 |
|
| 2476 |
``` cpp
|
| 2477 |
int do_frac_digits() const;
|
| 2478 |
```
|
| 2479 |
|
| 2480 |
*Returns:* The number of digits after the decimal radix separator, if
|
| 2481 |
-
any.[^
|
| 2482 |
|
| 2483 |
``` cpp
|
| 2484 |
pattern do_pos_format() const;
|
| 2485 |
pattern do_neg_format() const;
|
| 2486 |
```
|
|
@@ -2492,11 +2436,11 @@ pattern do_neg_format() const;
|
|
| 2492 |
- `moneypunct<wchar_t>`,
|
| 2493 |
- `moneypunct<char, true>`, and
|
| 2494 |
- `moneypunct<wchar_t, true>`,
|
| 2495 |
|
| 2496 |
return an object of type `pattern` initialized to
|
| 2497 |
-
`{ symbol, sign, none, value }`.[^
|
| 2498 |
|
| 2499 |
#### Class template `moneypunct_byname` <a id="locale.moneypunct.byname">[[locale.moneypunct.byname]]</a>
|
| 2500 |
|
| 2501 |
``` cpp
|
| 2502 |
namespace std {
|
|
@@ -2515,15 +2459,19 @@ namespace std {
|
|
| 2515 |
}
|
| 2516 |
```
|
| 2517 |
|
| 2518 |
### The message retrieval category <a id="category.messages">[[category.messages]]</a>
|
| 2519 |
|
|
|
|
|
|
|
| 2520 |
Class `messages<charT>` implements retrieval of strings from message
|
| 2521 |
catalogs.
|
| 2522 |
|
| 2523 |
#### Class template `messages` <a id="locale.messages">[[locale.messages]]</a>
|
| 2524 |
|
|
|
|
|
|
|
| 2525 |
``` cpp
|
| 2526 |
namespace std {
|
| 2527 |
class messages_base {
|
| 2528 |
public:
|
| 2529 |
using catalog = unspecified signed integer type;
|
|
|
|
| 1 |
## Standard `locale` categories <a id="locale.categories">[[locale.categories]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="locale.categories.general">[[locale.categories.general]]</a>
|
| 4 |
+
|
| 5 |
Each of the standard categories includes a family of facets. Some of
|
| 6 |
these implement formatting or parsing of a datum, for use by standard or
|
| 7 |
users’ iostream operators `<<` and `>>`, as members `put()` and `get()`,
|
| 8 |
respectively. Each such member function takes an `ios_base&` argument
|
| 9 |
whose members `flags()`, `precision()`, and `width()`, specify the
|
|
|
|
| 16 |
of the OutputIterator argument can be extracted from the returned
|
| 17 |
iterator.) The `get()` members take an `ios_base::iostate&` argument
|
| 18 |
whose value they ignore, but set to `ios_base::failbit` in case of a
|
| 19 |
parse error.
|
| 20 |
|
| 21 |
+
Within subclause [[locale.categories]] it is unspecified whether one
|
| 22 |
+
virtual function calls another virtual function.
|
| 23 |
|
| 24 |
### The `ctype` category <a id="category.ctype">[[category.ctype]]</a>
|
| 25 |
|
| 26 |
+
#### General <a id="category.ctype.general">[[category.ctype.general]]</a>
|
| 27 |
+
|
| 28 |
``` cpp
|
| 29 |
namespace std {
|
| 30 |
class ctype_base {
|
| 31 |
public:
|
| 32 |
using mask = see below;
|
|
|
|
| 50 |
|
| 51 |
The type `mask` is a bitmask type [[bitmask.types]].
|
| 52 |
|
| 53 |
#### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
|
| 54 |
|
| 55 |
+
##### General <a id="locale.ctype.general">[[locale.ctype.general]]</a>
|
| 56 |
+
|
| 57 |
``` cpp
|
| 58 |
namespace std {
|
| 59 |
template<class charT>
|
| 60 |
class ctype : public locale::facet, public ctype_base {
|
| 61 |
public:
|
|
|
|
| 225 |
const char* do_widen(const char* low, const char* high, charT* dest) const;
|
| 226 |
```
|
| 227 |
|
| 228 |
*Effects:* Applies the simplest reasonable transformation from a `char`
|
| 229 |
value or sequence of `char` values to the corresponding `charT` value or
|
| 230 |
+
values.[^5]
|
| 231 |
+
|
| 232 |
+
The only characters for which unique transformations are required are
|
| 233 |
+
those in the basic character set [[lex.charset]].
|
| 234 |
|
| 235 |
For any named `ctype` category with a `ctype<charT>` facet `ctc` and
|
| 236 |
valid `ctype_base::mask` value `M`,
|
| 237 |
`(ctc.is(M, c) || !is(M, do_widen(c)) )` is `true`.[^6]
|
| 238 |
|
|
|
|
| 249 |
|
| 250 |
*Effects:* Applies the simplest reasonable transformation from a `charT`
|
| 251 |
value or sequence of `charT` values to the corresponding `char` value or
|
| 252 |
values.
|
| 253 |
|
| 254 |
+
For any character `c` in the basic character set [[lex.charset]] the
|
| 255 |
+
transformation is such that
|
| 256 |
|
| 257 |
``` cpp
|
| 258 |
do_widen(do_narrow(c, 0)) == c
|
| 259 |
```
|
| 260 |
|
|
|
|
| 292 |
}
|
| 293 |
```
|
| 294 |
|
| 295 |
#### `ctype<char>` specialization <a id="facet.ctype.special">[[facet.ctype.special]]</a>
|
| 296 |
|
| 297 |
+
##### General <a id="facet.ctype.special.general">[[facet.ctype.special.general]]</a>
|
| 298 |
+
|
| 299 |
``` cpp
|
| 300 |
namespace std {
|
| 301 |
template<>
|
| 302 |
class ctype<char> : public locale::facet, public ctype_base {
|
| 303 |
public:
|
|
|
|
| 341 |
};
|
| 342 |
}
|
| 343 |
```
|
| 344 |
|
| 345 |
A specialization `ctype<char>` is provided so that the member functions
|
| 346 |
+
on type `char` can be implemented inline.[^7]
|
| 347 |
+
|
| 348 |
+
The *implementation-defined* value of member `table_size` is at least
|
| 349 |
+
256.
|
| 350 |
|
| 351 |
##### Destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
|
| 352 |
|
| 353 |
``` cpp
|
| 354 |
~ctype();
|
|
|
|
| 472 |
These functions are described identically as those members of the same
|
| 473 |
name in the `ctype` class template [[locale.ctype.members]].
|
| 474 |
|
| 475 |
#### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
|
| 476 |
|
| 477 |
+
##### General <a id="locale.codecvt.general">[[locale.codecvt.general]]</a>
|
| 478 |
+
|
| 479 |
``` cpp
|
| 480 |
namespace std {
|
| 481 |
class codecvt_base {
|
| 482 |
public:
|
| 483 |
enum result { ok, partial, error, noconv };
|
|
|
|
| 546 |
The specializations required in [[locale.category.facets]]
|
| 547 |
[[locale.category]] convert the implementation-defined native character
|
| 548 |
set. `codecvt<char, char, mbstate_t>` implements a degenerate
|
| 549 |
conversion; it does not convert at all. The specialization
|
| 550 |
`codecvt<char16_t, char8_t, mbstate_t>` converts between the UTF-16 and
|
| 551 |
+
UTF-8 encoding forms, and the specialization
|
| 552 |
+
`codecvt<char32_t, char8_t, mbstate_t>` converts between the UTF-32 and
|
| 553 |
+
UTF-8 encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts
|
| 554 |
+
between the native character sets for ordinary and wide characters.
|
| 555 |
+
Specializations on `mbstate_t` perform conversion between encodings
|
| 556 |
+
known to the library implementer. Other encodings can be converted by
|
| 557 |
+
specializing on a program-defined `stateT` type. Objects of type
|
| 558 |
+
`stateT` can contain any state that is useful to communicate to or from
|
| 559 |
+
the specialized `do_in` or `do_out` members.
|
| 560 |
|
| 561 |
##### Members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
|
| 562 |
|
| 563 |
``` cpp
|
| 564 |
result out(
|
|
|
|
| 671 |
|
| 672 |
[*Note 1*: As a result of operations on `state`, it can return `ok` or
|
| 673 |
`partial` and set `from_next == from` and
|
| 674 |
`to_next != to`. — *end note*]
|
| 675 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
*Returns:* An enumeration value, as summarized in
|
| 677 |
[[locale.codecvt.inout]].
|
| 678 |
|
| 679 |
**Table: `do_in/do_out` result values** <a id="locale.codecvt.inout">[locale.codecvt.inout]</a>
|
| 680 |
|
| 681 |
| Value | Meaning |
|
| 682 |
| --------- | ------------------------------------------------------------------------------------------------ |
|
| 683 |
| `ok` | completed the conversion |
|
| 684 |
| `partial` | not all source characters converted |
|
| 685 |
+
| `error` | encountered a character in {[}`from`, `from_end`{)} that cannot be converted |
|
| 686 |
| `noconv` | `internT` and `externT` are the same type, and input sequence is identical to converted sequence |
|
| 687 |
|
| 688 |
|
| 689 |
A return value of `partial`, if `(from_next == from_end)`, indicates
|
| 690 |
that either the destination sequence has not absorbed all the available
|
| 691 |
destination elements, or that additional source elements are needed
|
| 692 |
before another destination element can be produced.
|
| 693 |
|
| 694 |
+
*Remarks:* Its operations on `state` are unspecified.
|
| 695 |
+
|
| 696 |
+
[*Note 2*: This argument can be used, for example, to maintain shift
|
| 697 |
+
state, to specify conversion options (such as count only), or to
|
| 698 |
+
identify a cache of seek offsets. — *end note*]
|
| 699 |
+
|
| 700 |
``` cpp
|
| 701 |
result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
|
| 702 |
```
|
| 703 |
|
| 704 |
*Preconditions:* `(to <= to_end)` is well-defined and `true`; `state` is
|
| 705 |
initialized, if at the beginning of a sequence, or else is equal to the
|
| 706 |
result of converting the preceding characters in the sequence.
|
| 707 |
|
| 708 |
*Effects:* Places characters starting at `to` that should be appended to
|
| 709 |
terminate a sequence when the current `stateT` is given by `state`.[^9]
|
| 710 |
+
|
| 711 |
Stores no more than `(to_end - to)` destination elements, and leaves the
|
| 712 |
`to_next` pointer pointing one beyond the last element successfully
|
| 713 |
stored.
|
| 714 |
|
| 715 |
*Returns:* An enumeration value, as summarized in
|
|
|
|
| 785 |
}
|
| 786 |
```
|
| 787 |
|
| 788 |
### The numeric category <a id="category.numeric">[[category.numeric]]</a>
|
| 789 |
|
| 790 |
+
#### General <a id="category.numeric.general">[[category.numeric.general]]</a>
|
| 791 |
+
|
| 792 |
The classes `num_get<>` and `num_put<>` handle numeric formatting and
|
| 793 |
parsing. Virtual functions are provided for several numeric types.
|
| 794 |
Implementations may (but are not required to) delegate extraction of
|
| 795 |
smaller types to extractors for larger types.[^11]
|
| 796 |
|
|
|
|
| 805 |
`numpunct<>` facet to identify all numeric punctuation preferences, and
|
| 806 |
also for the `ctype<>` facet to perform character classification.
|
| 807 |
|
| 808 |
Extractor and inserter members of the standard iostreams use `num_get<>`
|
| 809 |
and `num_put<>` member functions for formatting and parsing numeric
|
| 810 |
+
values [[istream.formatted.reqmts]], [[ostream.formatted.reqmts]].
|
| 811 |
|
| 812 |
#### Class template `num_get` <a id="locale.num.get">[[locale.num.get]]</a>
|
| 813 |
|
| 814 |
+
##### General <a id="locale.num.get.general">[[locale.num.get.general]]</a>
|
| 815 |
+
|
| 816 |
``` cpp
|
| 817 |
namespace std {
|
| 818 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
| 819 |
class num_get : public locale::facet {
|
| 820 |
public:
|
|
|
|
| 945 |
determined in stage 1.
|
| 946 |
- Stage 3: Store results
|
| 947 |
|
| 948 |
The details of the stages are presented below.
|
| 949 |
|
| 950 |
+
[*Example 1*:
|
| 951 |
|
| 952 |
+
Given an input sequence of `"0x1a.bp+07p"`,
|
| 953 |
|
| 954 |
+
- if the conversion specifier returned by Stage 1 is `%d`, `"0"` is
|
| 955 |
+
accumulated;
|
| 956 |
+
- if the conversion specifier returned by Stage 1 is `%i`, `"0x1a"` are
|
| 957 |
+
accumulated;
|
| 958 |
+
- if the conversion specifier returned by Stage 1 is `%g`,
|
| 959 |
+
`"0x1a.bp+07"` are accumulated.
|
| 960 |
|
| 961 |
+
In all cases, the remainder is left in the input.
|
|
|
|
|
|
|
|
|
|
| 962 |
|
| 963 |
+
— *end example*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 964 |
|
| 965 |
Digit grouping is checked. That is, the positions of discarded
|
| 966 |
+
separators are examined for consistency with
|
| 967 |
`use_facet<numpunct<charT>>(loc).grouping()`. If they are not consistent
|
| 968 |
then `ios_base::failbit` is assigned to `err`.
|
| 969 |
|
| 970 |
In any case, if stage 2 processing was terminated by the test for
|
| 971 |
`in == end` then `err |= ios_base::eofbit` is performed.
|
|
|
|
| 998 |
`str.goodbit`; or to `str.eofbit` if, when seeking another character to
|
| 999 |
match, it is found that `(in == end)`. If `val` is not set, then `err`
|
| 1000 |
is set to `str.failbit`; or to `(str.failbit|str.eofbit)` if the reason
|
| 1001 |
for the failure was that `(in == end)`.
|
| 1002 |
|
| 1003 |
+
[*Example 2*: For targets `true`: `"a"` and `false`: `"abb"`, the input
|
| 1004 |
sequence `"a"` yields `val == true` and `err == str.eofbit`; the input
|
| 1005 |
sequence `"abc"` yields `err = str.failbit`, with `in` ending at the
|
| 1006 |
`’c’` element. For targets `true`: `"1"` and `false`: `"0"`, the input
|
| 1007 |
sequence `"1"` yields `val == true` and `err == str.goodbit`. For empty
|
| 1008 |
targets `("")`, any input sequence yields
|
|
|
|
| 1010 |
|
| 1011 |
*Returns:* `in`.
|
| 1012 |
|
| 1013 |
#### Class template `num_put` <a id="locale.nm.put">[[locale.nm.put]]</a>
|
| 1014 |
|
| 1015 |
+
##### General <a id="locale.nm.put.general">[[locale.nm.put.general]]</a>
|
| 1016 |
+
|
| 1017 |
``` cpp
|
| 1018 |
namespace std {
|
| 1019 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
| 1020 |
class num_put : public locale::facet {
|
| 1021 |
public:
|
|
|
|
| 1215 |
```
|
| 1216 |
|
| 1217 |
For arithmetic types, `punct.thousands_sep()` characters are inserted
|
| 1218 |
into the sequence as determined by the value returned by
|
| 1219 |
`punct.do_grouping()` using the method described
|
| 1220 |
+
in [[facet.numpunct.virtuals]].
|
| 1221 |
|
| 1222 |
+
Decimal point characters(.) are replaced by `punct.decimal_point()`.
|
| 1223 |
|
| 1224 |
- **Stage 3:**
|
| 1225 |
|
| 1226 |
A local variable is initialized as
|
| 1227 |
|
| 1228 |
``` cpp
|
| 1229 |
fmtflags adjustfield = (flags & (ios_base::adjustfield));
|
| 1230 |
```
|
| 1231 |
|
| 1232 |
+
The location of any padding[^12]
|
| 1233 |
+
|
| 1234 |
+
is determined according to [[facet.num.put.fill]].
|
| 1235 |
|
| 1236 |
**Table: Fill padding** <a id="facet.num.put.fill">[facet.num.put.fill]</a>
|
| 1237 |
|
| 1238 |
| State | Location |
|
| 1239 |
| ------------------------------------------------------------------------------ | ------------------ |
|
|
|
|
| 1278 |
|
| 1279 |
### The numeric punctuation facet <a id="facet.numpunct">[[facet.numpunct]]</a>
|
| 1280 |
|
| 1281 |
#### Class template `numpunct` <a id="locale.numpunct">[[locale.numpunct]]</a>
|
| 1282 |
|
| 1283 |
+
##### General <a id="locale.numpunct.general">[[locale.numpunct.general]]</a>
|
| 1284 |
+
|
| 1285 |
``` cpp
|
| 1286 |
namespace std {
|
| 1287 |
template<class charT>
|
| 1288 |
class numpunct : public locale::facet {
|
| 1289 |
public:
|
|
|
|
| 1309 |
virtual string_type do_falsename() const; // for bool
|
| 1310 |
};
|
| 1311 |
}
|
| 1312 |
```
|
| 1313 |
|
| 1314 |
+
`numpunct<>` specifies numeric punctuation. The specializations required
|
| 1315 |
+
in [[locale.category.facets]] [[locale.category]], namely
|
|
|
|
|
|
|
| 1316 |
`numpunct<{}wchar_t>` and `numpunct<char>`, provide classic `"C"`
|
| 1317 |
numeric formats, i.e., they contain information equivalent to that
|
| 1318 |
contained in the `"C"` locale or their wide character counterparts as if
|
| 1319 |
obtained by a call to `widen`.
|
| 1320 |
|
|
|
|
| 1419 |
``` cpp
|
| 1420 |
string do_grouping() const;
|
| 1421 |
```
|
| 1422 |
|
| 1423 |
*Returns:* A `string` `vec` used as a vector of integer values, in which
|
| 1424 |
+
each element `vec[i]` represents the number of digits[^13]
|
| 1425 |
+
|
| 1426 |
+
in the group at position `i`, starting with position 0 as the rightmost
|
| 1427 |
+
group. If `vec.size() <= i`, the number is the same as group `(i - 1)`;
|
| 1428 |
+
if `(i < 0 || vec[i] <= 0 || vec[i] == CHAR_MAX)`, the size of the digit
|
| 1429 |
group is unlimited.
|
| 1430 |
|
| 1431 |
The required specializations return the empty string, indicating no
|
| 1432 |
grouping.
|
| 1433 |
|
|
|
|
| 1464 |
|
| 1465 |
### The collate category <a id="category.collate">[[category.collate]]</a>
|
| 1466 |
|
| 1467 |
#### Class template `collate` <a id="locale.collate">[[locale.collate]]</a>
|
| 1468 |
|
| 1469 |
+
##### General <a id="locale.collate.general">[[locale.collate.general]]</a>
|
| 1470 |
+
|
| 1471 |
``` cpp
|
| 1472 |
namespace std {
|
| 1473 |
template<class charT>
|
| 1474 |
class collate : public locale::facet {
|
| 1475 |
public:
|
|
|
|
| 1499 |
(comparison) and hashing of strings. A locale member function template,
|
| 1500 |
`operator()`, uses the collate facet to allow a locale to act directly
|
| 1501 |
as the predicate argument for standard algorithms [[algorithms]] and
|
| 1502 |
containers operating on strings. The specializations required in
|
| 1503 |
[[locale.category.facets]] [[locale.category]], namely `collate<char>`
|
| 1504 |
+
and `collate<wchar_t>`, apply lexicographical ordering
|
| 1505 |
[[alg.lex.comparison]].
|
| 1506 |
|
| 1507 |
Each function compares a string of characters `*p` in the range \[`low`,
|
| 1508 |
`high`).
|
| 1509 |
|
|
|
|
| 1556 |
|
| 1557 |
*Returns:* An integer value equal to the result of calling `hash()` on
|
| 1558 |
any other string for which `do_compare()` returns 0 (equal) when passed
|
| 1559 |
the two strings.
|
| 1560 |
|
| 1561 |
+
*Recommended practice:* The probability that the result equals that for
|
| 1562 |
+
another string which does not compare equal should be very small,
|
| 1563 |
+
approaching `(1.0/numeric_limits<unsigned long>::max())`.
|
| 1564 |
|
| 1565 |
#### Class template `collate_byname` <a id="locale.collate.byname">[[locale.collate.byname]]</a>
|
| 1566 |
|
| 1567 |
``` cpp
|
| 1568 |
namespace std {
|
|
|
|
| 1580 |
}
|
| 1581 |
```
|
| 1582 |
|
| 1583 |
### The time category <a id="category.time">[[category.time]]</a>
|
| 1584 |
|
| 1585 |
+
#### General <a id="category.time.general">[[category.time.general]]</a>
|
| 1586 |
+
|
| 1587 |
Templates `time_get<charT, InputIterator>` and
|
| 1588 |
`time_put<charT, OutputIterator>` provide date and time formatting and
|
| 1589 |
parsing. All specifications of member functions for `time_put` and
|
| 1590 |
`time_get` in the subclauses of [[category.time]] only apply to the
|
| 1591 |
specializations required in Tables [[tab:locale.category.facets]] and
|
|
|
|
| 1594 |
[[locale.categories]], and the `ctype<>` facet, to determine formatting
|
| 1595 |
details.
|
| 1596 |
|
| 1597 |
#### Class template `time_get` <a id="locale.time.get">[[locale.time.get]]</a>
|
| 1598 |
|
| 1599 |
+
##### General <a id="locale.time.get.general">[[locale.time.get.general]]</a>
|
| 1600 |
+
|
| 1601 |
``` cpp
|
| 1602 |
namespace std {
|
| 1603 |
class time_base {
|
| 1604 |
public:
|
| 1605 |
enum dateorder { no_order, dmy, mdy, ymd, ydm };
|
|
|
|
| 1649 |
ios_base::iostate& err, tm* t, char format, char modifier) const;
|
| 1650 |
};
|
| 1651 |
}
|
| 1652 |
```
|
| 1653 |
|
| 1654 |
+
`time_get` is used to parse a character sequence, extracting components
|
| 1655 |
+
of a time or date into a `tm` object. Each `get` member parses a format
|
| 1656 |
+
as produced by a corresponding format specifier to `time_put<>::put`. If
|
|
|
|
|
|
|
| 1657 |
the sequence being parsed matches the correct format, the corresponding
|
| 1658 |
+
members of the `tm` argument are set to the values used to produce the
|
| 1659 |
+
sequence; otherwise either an error is reported or unspecified values
|
| 1660 |
+
are assigned.[^15]
|
| 1661 |
|
| 1662 |
If the end iterator is reached during parsing by any of the `get()`
|
| 1663 |
member functions, the member sets `ios_base::eofbit` in `err`.
|
| 1664 |
|
| 1665 |
##### Members <a id="locale.time.get.members">[[locale.time.get.members]]</a>
|
|
|
|
| 1725 |
- The expression `s == end` evaluates to `true`, in which case the
|
| 1726 |
function evaluates `err = ios_base::eofbit | ios_base::failbit`.
|
| 1727 |
- The next element of `fmt` is equal to `’%’`, optionally followed by a
|
| 1728 |
modifier character, followed by a conversion specifier character,
|
| 1729 |
`format`, together forming a conversion specification valid for the
|
| 1730 |
+
POSIX function `strptime`. If the number of elements in the range
|
| 1731 |
+
\[`fmt`, `fmtend`) is not sufficient to unambiguously determine
|
| 1732 |
whether the conversion specification is complete and valid, the
|
| 1733 |
function evaluates `err = ios_base::failbit`. Otherwise, the function
|
| 1734 |
evaluates `s = do_get(s, end, f, err, t, format, modifier)`, where the
|
| 1735 |
value of `modifier` is `’\0’` when the optional modifier is absent
|
| 1736 |
from the conversion specification. If `err == ios_base::goodbit` holds
|
|
|
|
| 1761 |
dateorder do_date_order() const;
|
| 1762 |
```
|
| 1763 |
|
| 1764 |
*Returns:* An enumeration value indicating the preferred order of
|
| 1765 |
components for those date formats that are composed of day, month, and
|
| 1766 |
+
year.[^16]
|
| 1767 |
+
|
| 1768 |
+
Returns `no_order` if the date format specified by `’x’` contains other
|
| 1769 |
+
variable components (e.g., Julian day, week number, week day).
|
| 1770 |
|
| 1771 |
``` cpp
|
| 1772 |
iter_type do_get_time(iter_type s, iter_type end, ios_base& str,
|
| 1773 |
ios_base::iostate& err, tm* t) const;
|
| 1774 |
```
|
| 1775 |
|
| 1776 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 1777 |
+
`tm` members, and remaining format characters, used by `time_put<>::put`
|
| 1778 |
+
to produce the format specified by `"%H:%M:%S"`, or until it encounters
|
| 1779 |
+
an error or end of sequence.
|
| 1780 |
|
| 1781 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1782 |
recognized as possibly part of a valid time.
|
| 1783 |
|
| 1784 |
``` cpp
|
| 1785 |
iter_type do_get_date(iter_type s, iter_type end, ios_base& str,
|
| 1786 |
ios_base::iostate& err, tm* t) const;
|
| 1787 |
```
|
| 1788 |
|
| 1789 |
*Effects:* Reads characters starting at `s` until it has extracted those
|
| 1790 |
+
`tm` members and remaining format characters used by `time_put<>::put`
|
| 1791 |
+
to produce one of the following formats, or until it encounters an
|
| 1792 |
+
error. The format depends on the value returned by `date_order()` as
|
| 1793 |
+
shown in [[locale.time.get.dogetdate]].
|
| 1794 |
|
| 1795 |
**Table: `do_get_date` effects** <a id="locale.time.get.dogetdate">[locale.time.get.dogetdate]</a>
|
| 1796 |
|
| 1797 |
| `date_order()` | Format |
|
| 1798 |
| -------------- | ---------- |
|
|
|
|
| 1816 |
ios_base::iostate& err, tm* t) const;
|
| 1817 |
```
|
| 1818 |
|
| 1819 |
*Effects:* Reads characters starting at `s` until it has extracted the
|
| 1820 |
(perhaps abbreviated) name of a weekday or month. If it finds an
|
| 1821 |
+
abbreviation that is followed by characters that can match a full name,
|
| 1822 |
+
it continues reading until it matches the full name or fails. It sets
|
| 1823 |
+
the appropriate `tm` member accordingly.
|
| 1824 |
|
| 1825 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1826 |
recognized as part of a valid name.
|
| 1827 |
|
| 1828 |
``` cpp
|
|
|
|
| 1845 |
|
| 1846 |
*Preconditions:* `t` points to an object.
|
| 1847 |
|
| 1848 |
*Effects:* The function starts by evaluating `err = ios_base::goodbit`.
|
| 1849 |
It then reads characters starting at `s` until it encounters an error,
|
| 1850 |
+
or until it has extracted and assigned those `tm` members, and any
|
| 1851 |
+
remaining format characters, corresponding to a conversion specification
|
| 1852 |
+
appropriate for the POSIX function `strptime`, formed by concatenating
|
| 1853 |
+
`’%’`, the `modifier` character, when non-NUL, and the `format`
|
| 1854 |
+
character. When the concatenation fails to yield a complete valid
|
| 1855 |
+
directive the function leaves the object pointed to by `t` unchanged and
|
| 1856 |
+
evaluates `err |= ios_base::failbit`. When `s == end` evaluates to
|
| 1857 |
+
`true` after reading a character the function evaluates
|
| 1858 |
`err |= ios_base::eofbit`.
|
| 1859 |
|
| 1860 |
+
For complex conversion specifications such as `%c`, `%x`, or `%X`, or
|
| 1861 |
+
conversion specifications that involve the optional modifiers `E` or
|
| 1862 |
+
`O`, when the function is unable to unambiguously determine some or all
|
| 1863 |
+
`tm` members from the input sequence \[`s`, `end`), it evaluates
|
| 1864 |
+
`err |= ios_base::eofbit`. In such cases the values of those `tm`
|
| 1865 |
members are unspecified and may be outside their valid range.
|
| 1866 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1867 |
*Returns:* An iterator pointing immediately beyond the last character
|
| 1868 |
recognized as possibly part of a valid input sequence for the given
|
| 1869 |
`format` and `modifier`.
|
| 1870 |
|
| 1871 |
+
*Remarks:* It is unspecified whether multiple calls to `do_get()` with
|
| 1872 |
+
the address of the same `tm` object will update the current contents of
|
| 1873 |
+
the object or simply overwrite its members. Portable programs should
|
| 1874 |
+
zero out the object before invoking the function.
|
| 1875 |
+
|
| 1876 |
#### Class template `time_get_byname` <a id="locale.time.get.byname">[[locale.time.get.byname]]</a>
|
| 1877 |
|
| 1878 |
``` cpp
|
| 1879 |
namespace std {
|
| 1880 |
template<class charT, class InputIterator = istreambuf_iterator<charT>>
|
|
|
|
| 1937 |
interleaved in the output in the order in which they appear in the
|
| 1938 |
pattern. Format sequences are identified by converting each character
|
| 1939 |
`c` to a `char` value as if by `ct.narrow(c, 0)`, where `ct` is a
|
| 1940 |
reference to `ctype<charT>` obtained from `str.getloc()`. The first
|
| 1941 |
character of each sequence is equal to `’%’`, followed by an optional
|
| 1942 |
+
modifier character `mod`[^17]
|
| 1943 |
+
|
| 1944 |
+
and a format specifier character `spec` as defined for the function
|
| 1945 |
+
`strftime`. If no modifier character is present, `mod` is zero. For each
|
| 1946 |
+
valid format sequence identified, calls
|
| 1947 |
`do_put(s, str, fill, t, spec, mod)`.
|
| 1948 |
|
| 1949 |
The second form calls `do_put(s, str, fill, t, format, modifier)`.
|
| 1950 |
|
| 1951 |
+
[*Note 1*: The `fill` argument can be used in the
|
| 1952 |
implementation-defined formats or by derivations. A space character is a
|
| 1953 |
reasonable default for this argument. — *end note*]
|
| 1954 |
|
| 1955 |
*Returns:* An iterator pointing immediately after the last character
|
| 1956 |
produced.
|
|
|
|
| 1964 |
|
| 1965 |
*Effects:* Formats the contents of the parameter `t` into characters
|
| 1966 |
placed on the output sequence `s`. Formatting is controlled by the
|
| 1967 |
parameters `format` and `modifier`, interpreted identically as the
|
| 1968 |
format specifiers in the string argument to the standard library
|
| 1969 |
+
function `strftime()`, except that the sequence of characters produced
|
| 1970 |
+
for those specifiers that are described as depending on the C locale are
|
| 1971 |
+
instead *implementation-defined*.
|
| 1972 |
+
|
| 1973 |
+
[*Note 2*: Interpretation of the `modifier` argument is
|
| 1974 |
+
implementation-defined. — *end note*]
|
| 1975 |
|
| 1976 |
*Returns:* An iterator pointing immediately after the last character
|
| 1977 |
produced.
|
| 1978 |
|
| 1979 |
+
[*Note 3*: The `fill` argument can be used in the
|
| 1980 |
implementation-defined formats or by derivations. A space character is a
|
| 1981 |
reasonable default for this argument. — *end note*]
|
| 1982 |
|
| 1983 |
+
*Recommended practice:* Interpretation of the `modifier` should follow
|
| 1984 |
+
POSIX conventions. Implementations should refer to other standards such
|
| 1985 |
+
as POSIX for a specification of the character sequences produced for
|
| 1986 |
+
those specifiers described as depending on the C locale.
|
| 1987 |
+
|
| 1988 |
#### Class template `time_put_byname` <a id="locale.time.put.byname">[[locale.time.put.byname]]</a>
|
| 1989 |
|
| 1990 |
``` cpp
|
| 1991 |
namespace std {
|
| 1992 |
template<class charT, class OutputIterator = ostreambuf_iterator<charT>>
|
|
|
|
| 2004 |
}
|
| 2005 |
```
|
| 2006 |
|
| 2007 |
### The monetary category <a id="category.monetary">[[category.monetary]]</a>
|
| 2008 |
|
| 2009 |
+
#### General <a id="category.monetary.general">[[category.monetary.general]]</a>
|
| 2010 |
+
|
| 2011 |
These templates handle monetary formats. A template parameter indicates
|
| 2012 |
whether local or international monetary formats are to be used.
|
| 2013 |
|
| 2014 |
All specifications of member functions for `money_put` and `money_get`
|
| 2015 |
in the subclauses of [[category.monetary]] only apply to the
|
|
|
|
| 2126 |
|
| 2127 |
Digits in the numeric monetary component are extracted and placed in
|
| 2128 |
`digits`, or into a character buffer `buf1` for conversion to produce a
|
| 2129 |
value for `units`, in the order in which they appear, preceded by a
|
| 2130 |
minus sign if and only if the result is negative. The value `units` is
|
| 2131 |
+
produced as if by[^18]
|
| 2132 |
|
| 2133 |
``` cpp
|
| 2134 |
for (int i = 0; i < n; ++i)
|
| 2135 |
buf2[i] = src[find(atoms, atoms+sizeof(src), buf1[i]) - atoms];
|
| 2136 |
buf2[n] = 0;
|
|
|
|
| 2217 |
leading minus sign and the immediately subsequent digit characters (as
|
| 2218 |
classified according to `ct`) are used; any trailing characters
|
| 2219 |
(including digits appearing after a non-digit character) are ignored.
|
| 2220 |
Calls `str.width(0)`.
|
| 2221 |
|
| 2222 |
+
*Returns:* An iterator pointing immediately after the last character
|
| 2223 |
+
produced.
|
| 2224 |
+
|
| 2225 |
*Remarks:* The currency symbol is generated if and only if
|
| 2226 |
`(str.flags() & str.showbase)` is nonzero. If the number of characters
|
| 2227 |
generated for the specified format is less than the value returned by
|
| 2228 |
`str.width()` on entry to the function, then copies of `fill` are
|
| 2229 |
inserted as necessary to pad to the specified width. For the value `af`
|
|
|
|
| 2235 |
|
| 2236 |
[*Note 1*: It is possible, with some combinations of format patterns
|
| 2237 |
and flag values, to produce output that cannot be parsed using
|
| 2238 |
`num_get<>::get`. — *end note*]
|
| 2239 |
|
|
|
|
|
|
|
|
|
|
| 2240 |
#### Class template `moneypunct` <a id="locale.moneypunct">[[locale.moneypunct]]</a>
|
| 2241 |
|
| 2242 |
+
##### General <a id="locale.moneypunct.general">[[locale.moneypunct.general]]</a>
|
| 2243 |
+
|
| 2244 |
``` cpp
|
| 2245 |
namespace std {
|
| 2246 |
class money_base {
|
| 2247 |
public:
|
| 2248 |
enum part { none, space, symbol, sign, value };
|
|
|
|
| 2287 |
|
| 2288 |
The `moneypunct<>` facet defines monetary formatting parameters used by
|
| 2289 |
`money_get<>` and `money_put<>`. A monetary format is a sequence of four
|
| 2290 |
components, specified by a `pattern` value `p`, such that the `part`
|
| 2291 |
value `static_cast<part>(p.field[i])` determines the `i`ᵗʰ component of
|
| 2292 |
+
the format[^19]
|
| 2293 |
+
|
| 2294 |
+
In the `field` member of a `pattern` object, each value `symbol`,
|
| 2295 |
+
`sign`, `value`, and either `space` or `none` appears exactly once. The
|
| 2296 |
+
value `none`, if present, is not first; the value `space`, if present,
|
| 2297 |
+
is neither first nor last.
|
| 2298 |
|
| 2299 |
Where `none` or `space` appears, whitespace is permitted in the format,
|
| 2300 |
except where `none` appears at the end, in which case no whitespace is
|
| 2301 |
permitted. The value `space` indicates that at least one space is
|
| 2302 |
required at that position. Where `symbol` appears, the sequence of
|
|
|
|
| 2378 |
``` cpp
|
| 2379 |
charT do_decimal_point() const;
|
| 2380 |
```
|
| 2381 |
|
| 2382 |
*Returns:* The radix separator to use in case `do_frac_digits()` is
|
| 2383 |
+
greater than zero.[^20]
|
| 2384 |
|
| 2385 |
``` cpp
|
| 2386 |
charT do_thousands_sep() const;
|
| 2387 |
```
|
| 2388 |
|
| 2389 |
*Returns:* The digit group separator to use in case `do_grouping()`
|
| 2390 |
+
specifies a digit grouping pattern.[^21]
|
| 2391 |
|
| 2392 |
``` cpp
|
| 2393 |
string do_grouping() const;
|
| 2394 |
```
|
| 2395 |
|
| 2396 |
*Returns:* A pattern defined identically as, but not necessarily equal
|
| 2397 |
+
to, the result of `numpunct<charT>::do_grouping()`.[^22]
|
| 2398 |
|
| 2399 |
``` cpp
|
| 2400 |
string_type do_curr_symbol() const;
|
| 2401 |
```
|
| 2402 |
|
|
|
|
| 2410 |
string_type do_positive_sign() const;
|
| 2411 |
string_type do_negative_sign() const;
|
| 2412 |
```
|
| 2413 |
|
| 2414 |
*Returns:* `do_positive_sign()` returns the string to use to indicate a
|
| 2415 |
+
positive monetary value;[^23]
|
| 2416 |
+
|
| 2417 |
+
`do_negative_sign()` returns the string to use to indicate a negative
|
| 2418 |
+
value.
|
| 2419 |
|
| 2420 |
``` cpp
|
| 2421 |
int do_frac_digits() const;
|
| 2422 |
```
|
| 2423 |
|
| 2424 |
*Returns:* The number of digits after the decimal radix separator, if
|
| 2425 |
+
any.[^24]
|
| 2426 |
|
| 2427 |
``` cpp
|
| 2428 |
pattern do_pos_format() const;
|
| 2429 |
pattern do_neg_format() const;
|
| 2430 |
```
|
|
|
|
| 2436 |
- `moneypunct<wchar_t>`,
|
| 2437 |
- `moneypunct<char, true>`, and
|
| 2438 |
- `moneypunct<wchar_t, true>`,
|
| 2439 |
|
| 2440 |
return an object of type `pattern` initialized to
|
| 2441 |
+
`{ symbol, sign, none, value }`.[^25]
|
| 2442 |
|
| 2443 |
#### Class template `moneypunct_byname` <a id="locale.moneypunct.byname">[[locale.moneypunct.byname]]</a>
|
| 2444 |
|
| 2445 |
``` cpp
|
| 2446 |
namespace std {
|
|
|
|
| 2459 |
}
|
| 2460 |
```
|
| 2461 |
|
| 2462 |
### The message retrieval category <a id="category.messages">[[category.messages]]</a>
|
| 2463 |
|
| 2464 |
+
#### General <a id="category.messages.general">[[category.messages.general]]</a>
|
| 2465 |
+
|
| 2466 |
Class `messages<charT>` implements retrieval of strings from message
|
| 2467 |
catalogs.
|
| 2468 |
|
| 2469 |
#### Class template `messages` <a id="locale.messages">[[locale.messages]]</a>
|
| 2470 |
|
| 2471 |
+
##### General <a id="locale.messages.general">[[locale.messages.general]]</a>
|
| 2472 |
+
|
| 2473 |
``` cpp
|
| 2474 |
namespace std {
|
| 2475 |
class messages_base {
|
| 2476 |
public:
|
| 2477 |
using catalog = unspecified signed integer type;
|