29 namespace json_details {
34 template<
typename Real>
35 DAW_ATTRIB_NOINLINE DAW_ATTRIB_NONNULL( ) [[nodiscard]] Real
36 parse_with_strtod(
char const *first,
char const *last ) {
37 static_assert( std::is_floating_point_v<Real>,
38 "Unexpected type passed to parse_with_strtod" );
39#if defined( DAW_JSON_USE_STRTOD )
42 if constexpr( std::is_same_v<Real, float> ) {
43 return static_cast<Real
>( std::strtof( first, end ) );
44 }
else if( std::is_same_v<Real, double> ) {
45 return static_cast<Real
>( std::strtod( first, end ) );
47 return static_cast<Real
>( std::strtold( first, end ) );
51 auto fc_res = std::from_chars( first, last, result );
52 if( fc_res.ec == std::errc::result_out_of_range ) {
54 return -std::numeric_limits<Real>::infinity( );
56 return std::numeric_limits<Real>::infinity( );
59 ErrorReason::InvalidNumber );