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

convert_to_number not called string_to_number, fixed usage of .fail enabling...

convert_to_number not called string_to_number, fixed usage of .fail enabling use for int double and other arithmetic types
parent 7495438f
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
......@@ -62,17 +62,17 @@ string_contains(const std::string &s, unsigned char ch)
return (s.find(ch) != std::string::npos);
}
template <typename T>
std::pair<bool, T>
convert_to_number(const std::string &str)
template <typename Precission>
std::pair<bool, Precission>
string_to_number(const std::string &str)
{
static_assert(std::is_same<T, double>::value || std::is_same<T, float>::value,
static_assert(std::is_arithmetic<Precission>::value,
"tokenize_comma_seperated_number_list can only produce float or double lists");
std::stringstream ss(str);
T number = 0;
Precission number = 0;
ss >> number;
if (ss.fail()) { return { false, 0 }; }
if (ss.good()) { return { false, 0 }; }
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