Skip to content

Commit 74dbb9a

Browse files
committed
Go back to stod
1 parent 7ed3934 commit 74dbb9a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ static int fc_int(const std::string& s) {
9797
return val;
9898
}
9999
static double fc_double(const std::string& s) {
100-
double val = 0.0;
101-
std::from_chars(s.data(), s.data() + s.size(), val);
102-
return val;
100+
return std::stod(s);
103101
}
104102
static const std::string& fc_string(const std::string& s) { return s; }
105103

src/synth.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ using MC = ArjunNS::Arjun::ManthanConf;
4242
template<typename T> T parse_val(const string& s) {
4343
T v{}; std::from_chars(s.data(), s.data() + s.size(), v); return v;
4444
}
45+
template<> double parse_val<double>(const string& s) {
46+
return std::stod(s);
47+
}
4548

4649
template<typename T> bool validate_val(const string& v) {
4750
T x; auto [p,e] = std::from_chars(v.data(), v.data()+v.size(), x);
4851
return e == std::errc{} && p == v.data()+v.size();
4952
}
53+
template<> bool validate_val<double>(const string& v) {
54+
try { size_t pos; std::stod(v, &pos); return pos == v.size(); }
55+
catch (...) { return false; }
56+
}
5057

5158
using PT = SynthRunner::ParamType;
5259
struct ParamDef { PT type; std::function<void(MC&, const string&)> setter; };

0 commit comments

Comments
 (0)