std::stof, std::stod, std::stold
Min standard notice:
Header: <string>
Interprets a floating point value in a string str.
# Declarations
float stof ( const std::string& str, std::size_t* pos = nullptr );
(since C++11)
float stof ( const std::wstring& str, std::size_t* pos = nullptr );
(since C++11)
double stod ( const std::string& str, std::size_t* pos = nullptr );
(since C++11)
double stod ( const std::wstring& str, std::size_t* pos = nullptr );
(since C++11)
long double stold( const std::string& str, std::size_t* pos = nullptr );
(since C++11)
long double stold( const std::wstring& str, std::size_t* pos = nullptr );
(since C++11)
# Parameters
str: the string to convertpos: address of an integer to store the number of characters processed
# Return value
The string converted to the specified floating point type.
# Example
This section is incompleteReason: no example
# Defect reports
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 2009 | C++11 | std::out_of_range would not be thrown if the convertedvalue would fall out of the range of the result type | will throw |
| LWG 2403 | C++11 | stof called std::strtod or std::wcstod | stof calls std::strtof or std::wcstof |