| 47 | } |
| 48 | |
| 49 | template <> std::optional<float> parse(std::string_view s) |
| 50 | { |
| 51 | trim(s); |
| 52 | trim(s, '+'); |
| 53 | |
| 54 | char buf[32]; |
| 55 | buf[sizeof(buf) - 1] = 0; |
| 56 | strncpy(buf, s.data(), std::min(s.size(), sizeof(buf) - 1)); |
| 57 | char* endptr = buf; |
| 58 | float value = strtof(buf, &endptr); |
| 59 | |
| 60 | if (endptr == buf) |
| 61 | return std::optional<float>(); |
| 62 | |
| 63 | return value; |
| 64 | } |
| 65 | |
| 66 | template <> std::optional<double> parse(std::string_view s) |
| 67 | { |