From Jason Turner

[string.conversions]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3trzx1xd/{from.md → to.md} +23 -22
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:* the first two functions call `strtod(str.c_str(), ptr)` and
36
- the third function calls `strtold(str.c_str(), ptr)`. Each function
37
- returns the converted result, if any. The argument `ptr` designates a
38
- pointer to an object internal to the function that is used to determine
39
- what to store at `*idx`. If the function does not throw an exception and
40
- `idx != 0`, the function stores in `*idx` the index of the first
41
- unconverted element of `str`.
42
 
43
  *Returns:* The converted result.
44
 
45
- *Throws:* `invalid_argument` if `strtod` or `strtold` reports that no
46
- conversion could be performed. Throws `out_of_range` if `strtod` or
47
- `strtold` sets `errno` to `ERANGE` or if the converted value is outside
48
- the range of representable values for the return type.
 
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:* the first two functions call `wcstod(str.c_str(), ptr)` and
101
- the third function calls `wcstold(str.c_str(), ptr)`. Each function
102
- returns the converted result, if any. The argument `ptr` designates a
103
- pointer to an object internal to the function that is used to determine
104
- what to store at `*idx`. If the function does not throw an exception and
105
- `idx != 0`, the function stores in `*idx` the index of the first
106
- unconverted element of `str`.
107
 
108
  *Returns:* The converted result.
109
 
110
- *Throws:* `invalid_argument` if `wcstod` or `wcstold` reports that no
111
- conversion could be performed. Throws `out_of_range` if `wcstod` or
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);