File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,7 @@ static int fc_int(const std::string& s) {
9797 return val;
9898}
9999static 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}
104102static const std::string& fc_string (const std::string& s) { return s; }
105103
Original file line number Diff line number Diff line change @@ -42,11 +42,18 @@ using MC = ArjunNS::Arjun::ManthanConf;
4242template <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
4649template <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
5158using PT = SynthRunner::ParamType;
5259struct ParamDef { PT type; std::function<void (MC&, const string&)> setter; };
You can’t perform that action at this time.
0 commit comments