mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-01-01 03:12:18 +08:00
Added trivial support for float32_t and float64_t
This commit is contained in:
parent
35d523195b
commit
f74e338e0a
@ -10,7 +10,7 @@
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <system_error>
|
||||
|
||||
#include <stdfloat>
|
||||
namespace fast_float {
|
||||
|
||||
|
||||
@ -137,6 +137,26 @@ template<typename T, typename UC>
|
||||
FASTFLOAT_CONSTEXPR20
|
||||
from_chars_result_t<UC> 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<T, std::float32_t>::value){
|
||||
float value32;
|
||||
from_chars_result_t<UC> ret = from_chars_advanced(first, last, value32, parse_options_t<UC>{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<T, std::float64_t>::value){
|
||||
double value64;
|
||||
from_chars_result_t<UC> ret = from_chars_advanced(first, last, value64, parse_options_t<UC>{fmt});
|
||||
value = value64;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return from_chars_advanced(first, last, value, parse_options_t<UC>{fmt});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user