std::stof, std::stod, std::stold

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

# Return value

The string converted to the specified floating point type.

# Example

This section is incompleteReason: no example

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 2009C++11std::out_of_range would not be thrown if the convertedvalue would fall out of the range of the result typewill throw
LWG 2403C++11stof called std::strtod or std::wcstodstof calls std::strtof or std::wcstof

# See also