21 #ifdef USE_FALLBACK_CHARCONV
26 T string_to_floating_point(
const char* str,
char** str_end) =
delete;
28 float string_to_floating_point(
const char* str,
char** str_end)
30 return std::strtof(str, str_end);
33 double string_to_floating_point(
const char* str,
char** str_end)
35 return std::strtod(str, str_end);
38 long double string_to_floating_point(
const char* str,
char** str_end)
40 return std::strtold(str, str_end);
46 std::enable_if_t<std::is_same_v<T, double> || std::is_same_v<T, float> || std::is_same_v<T, long double>,
from_chars_result>
from_chars(
const char* first,
const char* last, T& value,
chars_format fmt)
52 std::string buffer = std::string(first, last);
54 if(buffer.empty() || std::isspace(buffer.front()) || buffer.front() ==
'+' ) {
55 return { first, std::errc::invalid_argument };
59 locale_t l = newlocale(LC_ALL,
"C",
static_cast<locale_t
>(0));
60 locale_t l_prev = uselocale(l);
63 char* str_end =
nullptr;
64 value = string_to_floating_point<T>( buffer.data(), &str_end );
69 if(str_end == buffer.data()) {
70 return { first, std::errc::invalid_argument };
72 return { first + (str_end - buffer.data()), std::errc() };
std::enable_if_t< std::is_integral_v< T >, from_chars_result > from_chars(const char *first, const char *last, T &value, int base=10)
charconv_impl::from_chars_result from_chars_result
charconv_impl::chars_format chars_format