| 201 | } |
| 202 | |
| 203 | bool try_to_string(std::string* out, const f64& value) |
| 204 | { |
| 205 | #ifdef __APPLE__ |
| 206 | if (out) *out = std::to_string(value); |
| 207 | return true; |
| 208 | #else |
| 209 | std::array<char, 32> str{}; |
| 210 | |
| 211 | if (auto [ptr, ec] = std::to_chars(str.data(), str.data() + str.size(), value, std::chars_format::fixed); ec == std::errc()) |
| 212 | { |
| 213 | if (out) *out = std::string(str.data(), ptr); |
| 214 | return true; |
| 215 | } |
| 216 | else |
| 217 | { |
| 218 | if (out) cfg_log.error("cfg::try_to_string(): could not convert value '%f' to string. error='%s'", value, std::make_error_code(ec).message()); |
| 219 | return false; |
| 220 | } |
| 221 | #endif |
| 222 | } |
| 223 | |
| 224 | bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) func, std::string_view value) |
| 225 | { |