From f74e338e0a9df04c02fe840b0d9d3c7b0a31a574 Mon Sep 17 00:00:00 2001 From: MTahaK Date: Tue, 12 Dec 2023 16:38:48 -0500 Subject: [PATCH] Added trivial support for float32_t and float64_t --- include/fast_float/parse_number.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 1c8afa4..3498fba 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -10,7 +10,7 @@ #include #include #include - +#include namespace fast_float { @@ -137,6 +137,26 @@ template FASTFLOAT_CONSTEXPR20 from_chars_result_t from_chars(UC const * first, UC const * last, T &value, chars_format fmt /*= chars_format::general*/) noexcept { +#ifdef __STDCPP_FLOAT32_T__ == 1 + // if std::float32_t is defined, then we are in C++23 mode; call value as a float + // due to equivalence between float and float32_t + if(std::is_same::value){ + float value32; + from_chars_result_t ret = from_chars_advanced(first, last, value32, parse_options_t{fmt}); + value = value32; + return ret; + } +#endif +#ifdef __STDCPP_FLOAT64_T__ == 1 + // if std::float64_t is defined, then we are in C++23 mode; call value as a double + // due to equivalence between double and float64_t + if(std::is_same::value){ + double value64; + from_chars_result_t ret = from_chars_advanced(first, last, value64, parse_options_t{fmt}); + value = value64; + return ret; + } +#endif return from_chars_advanced(first, last, value, parse_options_t{fmt}); }