| 34 | } |
| 35 | |
| 36 | static double toDouble(const std::string& value) |
| 37 | { |
| 38 | try |
| 39 | { |
| 40 | size_t idx; |
| 41 | double d = std::stod(value, &idx); |
| 42 | if (value[idx] != '\0') |
| 43 | throw std::invalid_argument("trailing garbage"); |
| 44 | return d; |
| 45 | } |
| 46 | catch (const std::invalid_argument& e) |
| 47 | { |
| 48 | error("invalid number '{}'", value); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | static int64_t toInt64(const std::string& value) |
| 53 | { |