tmp/tmphnk2ya97/{from.md → to.md}
RENAMED
|
@@ -1,9 +1,17 @@
|
|
| 1 |
## Primitive numeric conversions <a id="charconv">[[charconv]]</a>
|
| 2 |
|
| 3 |
### Header `<charconv>` synopsis <a id="charconv.syn">[[charconv.syn]]</a>
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
``` cpp
|
| 6 |
%
|
| 7 |
%
|
| 8 |
{chars_format{chars_format{chars_format{chars_formatnamespace std {
|
| 9 |
// floating-point format for primitive numerical conversion
|
|
@@ -22,26 +30,16 @@
|
|
| 22 |
char* ptr;
|
| 23 |
errc ec;
|
| 24 |
friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
|
| 25 |
};
|
| 26 |
|
| 27 |
-
to_chars_result to_chars(char* first, char* last,
|
| 28 |
to_chars_result to_chars(char* first, char* last, bool value, int base = 10) = delete;
|
| 29 |
|
| 30 |
-
to_chars_result to_chars(char* first, char* last,
|
| 31 |
-
to_chars_result to_chars(char* first, char* last,
|
| 32 |
-
to_chars_result to_chars(char* first, char* last,
|
| 33 |
-
|
| 34 |
-
to_chars_result to_chars(char* first, char* last, float value, chars_format fmt);
|
| 35 |
-
to_chars_result to_chars(char* first, char* last, double value, chars_format fmt);
|
| 36 |
-
to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt);
|
| 37 |
-
|
| 38 |
-
to_chars_result to_chars(char* first, char* last, float value,
|
| 39 |
-
chars_format fmt, int precision);
|
| 40 |
-
to_chars_result to_chars(char* first, char* last, double value,
|
| 41 |
-
chars_format fmt, int precision);
|
| 42 |
-
to_chars_result to_chars(char* first, char* last, long double value,
|
| 43 |
chars_format fmt, int precision);
|
| 44 |
%
|
| 45 |
%
|
| 46 |
{from_chars_result{from_chars_result}
|
| 47 |
|
|
@@ -50,18 +48,14 @@
|
|
| 50 |
const char* ptr;
|
| 51 |
errc ec;
|
| 52 |
friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
|
| 53 |
};
|
| 54 |
|
| 55 |
-
from_chars_result from_chars(const char* first, const char* last,
|
| 56 |
-
|
| 57 |
|
| 58 |
-
from_chars_result from_chars(const char* first, const char* last,
|
| 59 |
-
chars_format fmt = chars_format::general);
|
| 60 |
-
from_chars_result from_chars(const char* first, const char* last, double& value,
|
| 61 |
-
chars_format fmt = chars_format::general);
|
| 62 |
-
from_chars_result from_chars(const char* first, const char* last, long double& value,
|
| 63 |
chars_format fmt = chars_format::general);
|
| 64 |
}
|
| 65 |
```
|
| 66 |
|
| 67 |
The type `chars_format` is a bitmask type [[bitmask.types]] with
|
|
@@ -103,11 +97,11 @@ specifier for `printf` as follows: The conversion specifier is `f` if
|
|
| 103 |
`chars_format::scientific`, `a` (without leading `"0x"` in the result)
|
| 104 |
if `fmt` is `chars_format::hex`, and `g` if `fmt` is
|
| 105 |
`chars_format::general`.
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
-
to_chars_result to_chars(char* first, char* last,
|
| 109 |
```
|
| 110 |
|
| 111 |
*Preconditions:* `base` has a value between 2 and 36 (inclusive).
|
| 112 |
|
| 113 |
*Effects:* The value of `value` is converted to a string of digits in
|
|
@@ -115,30 +109,23 @@ the given base (with no redundant leading zeroes). Digits in the range
|
|
| 115 |
10..35 (inclusive) are represented as lowercase characters `a`..`z`. If
|
| 116 |
`value` is less than zero, the representation starts with `’-’`.
|
| 117 |
|
| 118 |
*Throws:* Nothing.
|
| 119 |
|
| 120 |
-
*Remarks:* The implementation shall provide overloads for all signed and
|
| 121 |
-
unsigned integer types and `char` as the type of the parameter `value`.
|
| 122 |
-
|
| 123 |
``` cpp
|
| 124 |
-
to_chars_result to_chars(char* first, char* last,
|
| 125 |
-
to_chars_result to_chars(char* first, char* last, double value);
|
| 126 |
-
to_chars_result to_chars(char* first, char* last, long double value);
|
| 127 |
```
|
| 128 |
|
| 129 |
*Effects:* `value` is converted to a string in the style of `printf` in
|
| 130 |
the `"C"` locale. The conversion specifier is `f` or `e`, chosen
|
| 131 |
according to the requirement for a shortest representation (see above);
|
| 132 |
a tie is resolved in favor of `f`.
|
| 133 |
|
| 134 |
*Throws:* Nothing.
|
| 135 |
|
| 136 |
``` cpp
|
| 137 |
-
to_chars_result to_chars(char* first, char* last,
|
| 138 |
-
to_chars_result to_chars(char* first, char* last, double value, chars_format fmt);
|
| 139 |
-
to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt);
|
| 140 |
```
|
| 141 |
|
| 142 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 143 |
`chars_format`.
|
| 144 |
|
|
@@ -146,15 +133,11 @@ to_chars_result to_chars(char* first, char* last, long double value, chars_forma
|
|
| 146 |
the `"C"` locale.
|
| 147 |
|
| 148 |
*Throws:* Nothing.
|
| 149 |
|
| 150 |
``` cpp
|
| 151 |
-
to_chars_result to_chars(char* first, char* last,
|
| 152 |
-
chars_format fmt, int precision);
|
| 153 |
-
to_chars_result to_chars(char* first, char* last, double value,
|
| 154 |
-
chars_format fmt, int precision);
|
| 155 |
-
to_chars_result to_chars(char* first, char* last, long double value,
|
| 156 |
chars_format fmt, int precision);
|
| 157 |
```
|
| 158 |
|
| 159 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 160 |
`chars_format`.
|
|
@@ -187,12 +170,12 @@ unmodified and the member `ec` of the return value is equal to
|
|
| 187 |
`errc::result_out_of_range`. Otherwise, `value` is set to the parsed
|
| 188 |
value, after rounding according to `round_to_nearest` [[round.style]],
|
| 189 |
and the member `ec` is value-initialized.
|
| 190 |
|
| 191 |
``` cpp
|
| 192 |
-
from_chars_result from_chars(const char* first, const char* last,
|
| 193 |
-
|
| 194 |
```
|
| 195 |
|
| 196 |
*Preconditions:* `base` has a value between 2 and 36 (inclusive).
|
| 197 |
|
| 198 |
*Effects:* The pattern is the expected form of the subject sequence in
|
|
@@ -201,20 +184,12 @@ except that no `"0x"` or `"0X"` prefix shall appear if the value of
|
|
| 201 |
`base` is 16, and except that `’-’` is the only sign that may appear,
|
| 202 |
and only if `value` has a signed type.
|
| 203 |
|
| 204 |
*Throws:* Nothing.
|
| 205 |
|
| 206 |
-
*Remarks:* The implementation shall provide overloads for all signed and
|
| 207 |
-
unsigned integer types and `char` as the referenced type of the
|
| 208 |
-
parameter `value`.
|
| 209 |
-
|
| 210 |
``` cpp
|
| 211 |
-
from_chars_result from_chars(const char* first, const char* last,
|
| 212 |
-
chars_format fmt = chars_format::general);
|
| 213 |
-
from_chars_result from_chars(const char* first, const char* last, double& value,
|
| 214 |
-
chars_format fmt = chars_format::general);
|
| 215 |
-
from_chars_result from_chars(const char* first, const char* last, long double& value,
|
| 216 |
chars_format fmt = chars_format::general);
|
| 217 |
```
|
| 218 |
|
| 219 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 220 |
`chars_format`.
|
|
|
|
| 1 |
## Primitive numeric conversions <a id="charconv">[[charconv]]</a>
|
| 2 |
|
| 3 |
### Header `<charconv>` synopsis <a id="charconv.syn">[[charconv.syn]]</a>
|
| 4 |
|
| 5 |
+
When a function is specified with a type placeholder of `integer-type`,
|
| 6 |
+
the implementation provides overloads for all cv-unqualified signed and
|
| 7 |
+
unsigned integer types and `char` in lieu of `integer-type`. When a
|
| 8 |
+
function is specified with a type placeholder of `floating-point-type`,
|
| 9 |
+
the implementation provides overloads for all cv-unqualified
|
| 10 |
+
floating-point types [[basic.fundamental]] in lieu of
|
| 11 |
+
`floating-point-type`.
|
| 12 |
+
|
| 13 |
``` cpp
|
| 14 |
%
|
| 15 |
%
|
| 16 |
{chars_format{chars_format{chars_format{chars_formatnamespace std {
|
| 17 |
// floating-point format for primitive numerical conversion
|
|
|
|
| 30 |
char* ptr;
|
| 31 |
errc ec;
|
| 32 |
friend bool operator==(const to_chars_result&, const to_chars_result&) = default;
|
| 33 |
};
|
| 34 |
|
| 35 |
+
constexpr to_chars_result to_chars(char* first, char* last, integer-type value, int base = 10);
|
| 36 |
to_chars_result to_chars(char* first, char* last, bool value, int base = 10) = delete;
|
| 37 |
|
| 38 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value);
|
| 39 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value, chars_format fmt);
|
| 40 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
chars_format fmt, int precision);
|
| 42 |
%
|
| 43 |
%
|
| 44 |
{from_chars_result{from_chars_result}
|
| 45 |
|
|
|
|
| 48 |
const char* ptr;
|
| 49 |
errc ec;
|
| 50 |
friend bool operator==(const from_chars_result&, const from_chars_result&) = default;
|
| 51 |
};
|
| 52 |
|
| 53 |
+
constexpr from_chars_result from_chars(const char* first, const char* last,
|
| 54 |
+
integer-type& value, int base = 10);
|
| 55 |
|
| 56 |
+
from_chars_result from_chars(const char* first, const char* last, floating-point-type& value,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
chars_format fmt = chars_format::general);
|
| 58 |
}
|
| 59 |
```
|
| 60 |
|
| 61 |
The type `chars_format` is a bitmask type [[bitmask.types]] with
|
|
|
|
| 97 |
`chars_format::scientific`, `a` (without leading `"0x"` in the result)
|
| 98 |
if `fmt` is `chars_format::hex`, and `g` if `fmt` is
|
| 99 |
`chars_format::general`.
|
| 100 |
|
| 101 |
``` cpp
|
| 102 |
+
constexpr to_chars_result to_chars(char* first, char* last, integer-type value, int base = 10);
|
| 103 |
```
|
| 104 |
|
| 105 |
*Preconditions:* `base` has a value between 2 and 36 (inclusive).
|
| 106 |
|
| 107 |
*Effects:* The value of `value` is converted to a string of digits in
|
|
|
|
| 109 |
10..35 (inclusive) are represented as lowercase characters `a`..`z`. If
|
| 110 |
`value` is less than zero, the representation starts with `’-’`.
|
| 111 |
|
| 112 |
*Throws:* Nothing.
|
| 113 |
|
|
|
|
|
|
|
|
|
|
| 114 |
``` cpp
|
| 115 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value);
|
|
|
|
|
|
|
| 116 |
```
|
| 117 |
|
| 118 |
*Effects:* `value` is converted to a string in the style of `printf` in
|
| 119 |
the `"C"` locale. The conversion specifier is `f` or `e`, chosen
|
| 120 |
according to the requirement for a shortest representation (see above);
|
| 121 |
a tie is resolved in favor of `f`.
|
| 122 |
|
| 123 |
*Throws:* Nothing.
|
| 124 |
|
| 125 |
``` cpp
|
| 126 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value, chars_format fmt);
|
|
|
|
|
|
|
| 127 |
```
|
| 128 |
|
| 129 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 130 |
`chars_format`.
|
| 131 |
|
|
|
|
| 133 |
the `"C"` locale.
|
| 134 |
|
| 135 |
*Throws:* Nothing.
|
| 136 |
|
| 137 |
``` cpp
|
| 138 |
+
to_chars_result to_chars(char* first, char* last, floating-point-type value,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
chars_format fmt, int precision);
|
| 140 |
```
|
| 141 |
|
| 142 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 143 |
`chars_format`.
|
|
|
|
| 170 |
`errc::result_out_of_range`. Otherwise, `value` is set to the parsed
|
| 171 |
value, after rounding according to `round_to_nearest` [[round.style]],
|
| 172 |
and the member `ec` is value-initialized.
|
| 173 |
|
| 174 |
``` cpp
|
| 175 |
+
constexpr from_chars_result from_chars(const char* first, const char* last,
|
| 176 |
+
integer-type& value, int base = 10);
|
| 177 |
```
|
| 178 |
|
| 179 |
*Preconditions:* `base` has a value between 2 and 36 (inclusive).
|
| 180 |
|
| 181 |
*Effects:* The pattern is the expected form of the subject sequence in
|
|
|
|
| 184 |
`base` is 16, and except that `’-’` is the only sign that may appear,
|
| 185 |
and only if `value` has a signed type.
|
| 186 |
|
| 187 |
*Throws:* Nothing.
|
| 188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
``` cpp
|
| 190 |
+
from_chars_result from_chars(const char* first, const char* last, floating-point-type& value,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
chars_format fmt = chars_format::general);
|
| 192 |
```
|
| 193 |
|
| 194 |
*Preconditions:* `fmt` has the value of one of the enumerators of
|
| 195 |
`chars_format`.
|