10 namespace fly::detail {
27 static std::optional<T> convert(
const std::string &value)
29 const char *begin = value.data();
30 const char *end = begin + value.size();
33 auto result = std::from_chars(begin, end, converted);
35 if ((result.ptr != end) || (result.ec != std::errc {}))
44 #if !defined(FLY_COMPILER_SUPPORTS_FP_CHARCONV)
50 static std::optional<float> convert(
const std::string &value)
52 std::size_t index = 0;
57 result = std::stof(value, &index);
64 if (index != value.length())
77 static std::optional<double> convert(
const std::string &value)
79 std::size_t index = 0;
84 result = std::stod(value, &index);
91 if (index != value.length())
104 static std::optional<long double> convert(
const std::string &value)
106 std::size_t index = 0;
107 long double result {};
111 result = std::stold(value, &index);
118 if (index != value.length())
Definition: converter.hpp:26