Skip to content
Snippets Groups Projects
Commit 8d45ed25 authored by Oliver Heidmann's avatar Oliver Heidmann Committed by Uwe Schulzweida
Browse files

fixed string_to_number

- fixed error message
- fixed good being used and replaced it with eof
- returns nan on error
parent b491385d
No related branches found
No related tags found
2 merge requests!326convert_to_number not called string_to_number, fixed usage of .fail enabling...,!322Fixing and cleaning up handling of operator argument sourrounding the use of scientific notations
......@@ -63,16 +63,15 @@ string_contains(const std::string &s, unsigned char ch)
}
template <typename Precission>
std::pair<bool, Precission>
std::tuple<bool, Precission>
string_to_number(const std::string &str)
{
static_assert(std::is_arithmetic<Precission>::value,
"tokenize_comma_seperated_number_list can only produce float or double lists");
static_assert(std::is_arithmetic<Precission>::value, "Only arithmetic types allowed");
std::stringstream ss(str);
Precission number = 0;
ss >> number;
if (ss.good()) { return { false, 0 }; }
Precission number = 0.0;
ss >> number;
if (!ss.eof()) { return { false, std::numeric_limits<Precission>::quiet_NaN() }; }
return { true, number };
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment