tmp/tmp3trzx1xd/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
## Numeric conversions <a id="string.conversions">[[string.conversions]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
int stoi(const string& str, size_t* idx = 0, int base = 10);
|
| 5 |
long stol(const string& str, size_t* idx = 0, int base = 10);
|
| 6 |
unsigned long stoul(const string& str, size_t* idx = 0, int base = 10);
|
|
@@ -30,24 +30,25 @@ representable values for the return type.
|
|
| 30 |
float stof(const string& str, size_t* idx = 0);
|
| 31 |
double stod(const string& str, size_t* idx = 0);
|
| 32 |
long double stold(const string& str, size_t* idx = 0);
|
| 33 |
```
|
| 34 |
|
| 35 |
-
*Effects:*
|
| 36 |
-
|
| 37 |
-
returns the converted result, if any. The
|
| 38 |
-
pointer to an object internal to the
|
| 39 |
-
what to store at `*idx`. If the
|
| 40 |
-
`idx != 0`, the function stores
|
| 41 |
-
unconverted element of `str`.
|
| 42 |
|
| 43 |
*Returns:* The converted result.
|
| 44 |
|
| 45 |
-
*Throws:* `invalid_argument` if `strtod` or `strtold` reports
|
| 46 |
-
conversion could be performed. Throws `out_of_range` if
|
| 47 |
-
`strtold` sets `errno` to `ERANGE` or if the
|
| 48 |
-
the range of representable values for the
|
|
|
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
string to_string(int val);
|
| 52 |
string to_string(unsigned val);
|
| 53 |
string to_string(long val);
|
|
@@ -95,23 +96,23 @@ representable values for the return type.
|
|
| 95 |
float stof(const wstring& str, size_t* idx = 0);
|
| 96 |
double stod(const wstring& str, size_t* idx = 0);
|
| 97 |
long double stold(const wstring& str, size_t* idx = 0);
|
| 98 |
```
|
| 99 |
|
| 100 |
-
*Effects:*
|
| 101 |
-
|
| 102 |
-
returns the converted result, if any. The
|
| 103 |
-
pointer to an object internal to the
|
| 104 |
-
what to store at `*idx`. If the
|
| 105 |
-
`idx != 0`, the function stores
|
| 106 |
-
unconverted element of `str`.
|
| 107 |
|
| 108 |
*Returns:* The converted result.
|
| 109 |
|
| 110 |
-
*Throws:* `invalid_argument` if `wcstod` or `wcstold` reports
|
| 111 |
-
conversion could be performed. Throws `out_of_range` if
|
| 112 |
-
`wcstold` sets `errno` to `ERANGE`.
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
wstring to_wstring(int val);
|
| 116 |
wstring to_wstring(unsigned val);
|
| 117 |
wstring to_wstring(long val);
|
|
|
|
| 1 |
+
### Numeric conversions <a id="string.conversions">[[string.conversions]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
int stoi(const string& str, size_t* idx = 0, int base = 10);
|
| 5 |
long stol(const string& str, size_t* idx = 0, int base = 10);
|
| 6 |
unsigned long stoul(const string& str, size_t* idx = 0, int base = 10);
|
|
|
|
| 30 |
float stof(const string& str, size_t* idx = 0);
|
| 31 |
double stod(const string& str, size_t* idx = 0);
|
| 32 |
long double stold(const string& str, size_t* idx = 0);
|
| 33 |
```
|
| 34 |
|
| 35 |
+
*Effects:* These functions call `strtof(str.c_str(), ptr)`,
|
| 36 |
+
`strtod(str.c_str(), ptr)`, and `strtold(str.c_str(), ptr)`,
|
| 37 |
+
respectively. Each function returns the converted result, if any. The
|
| 38 |
+
argument `ptr` designates a pointer to an object internal to the
|
| 39 |
+
function that is used to determine what to store at `*idx`. If the
|
| 40 |
+
function does not throw an exception and `idx != 0`, the function stores
|
| 41 |
+
in `*idx` the index of the first unconverted element of `str`.
|
| 42 |
|
| 43 |
*Returns:* The converted result.
|
| 44 |
|
| 45 |
+
*Throws:* `invalid_argument` if `strtof`, `strtod`, or `strtold` reports
|
| 46 |
+
that no conversion could be performed. Throws `out_of_range` if
|
| 47 |
+
`strtof`, `strtod`, or `strtold` sets `errno` to `ERANGE` or if the
|
| 48 |
+
converted value is outside the range of representable values for the
|
| 49 |
+
return type.
|
| 50 |
|
| 51 |
``` cpp
|
| 52 |
string to_string(int val);
|
| 53 |
string to_string(unsigned val);
|
| 54 |
string to_string(long val);
|
|
|
|
| 96 |
float stof(const wstring& str, size_t* idx = 0);
|
| 97 |
double stod(const wstring& str, size_t* idx = 0);
|
| 98 |
long double stold(const wstring& str, size_t* idx = 0);
|
| 99 |
```
|
| 100 |
|
| 101 |
+
*Effects:* These functions call `wcstof(str.c_str(), ptr)`,
|
| 102 |
+
`wcstod(str.c_str(), ptr)`, and `wcstold(str.c_str(), ptr)`,
|
| 103 |
+
respectively. Each function returns the converted result, if any. The
|
| 104 |
+
argument `ptr` designates a pointer to an object internal to the
|
| 105 |
+
function that is used to determine what to store at `*idx`. If the
|
| 106 |
+
function does not throw an exception and `idx != 0`, the function stores
|
| 107 |
+
in `*idx` the index of the first unconverted element of `str`.
|
| 108 |
|
| 109 |
*Returns:* The converted result.
|
| 110 |
|
| 111 |
+
*Throws:* `invalid_argument` if `wcstof`, `wcstod`, or `wcstold` reports
|
| 112 |
+
that no conversion could be performed. Throws `out_of_range` if
|
| 113 |
+
`wcstof`, `wcstod`, or `wcstold` sets `errno` to `ERANGE`.
|
| 114 |
|
| 115 |
``` cpp
|
| 116 |
wstring to_wstring(int val);
|
| 117 |
wstring to_wstring(unsigned val);
|
| 118 |
wstring to_wstring(long val);
|