From e84f289337816df8e26e270238ee2e1334d4a5cf Mon Sep 17 00:00:00 2001 From: IRainman Date: Wed, 12 Mar 2025 18:45:48 +0300 Subject: [PATCH] FASTFLOAT_IF_CONSTEXPR17 fix compilation when FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN isn't enabled. --- include/fast_float/ascii_number.h | 22 +++++++++++----------- include/fast_float/parse_number.h | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index 4f4c9d9..dcaffca 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -240,11 +240,15 @@ loop_parse_if_eight_digits(char const *&p, char const *const pend, enum class parse_error { no_error, + // A sign must be followed by an integer or dot. + missing_integer_or_dot_after_sign, + // The mantissa must have at least one digit. + no_digits_in_mantissa, + // Scientific notation requires an exponential part. + missing_exponential_part, #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN // [JSON-only] The minus sign must be followed by an integer. missing_integer_after_sign, - // A sign must be followed by an integer or dot. - missing_integer_or_dot_after_sign, // [JSON-only] The integer part must not have leading zeros. leading_zeros_in_integer_part, // [JSON-only] The integer part must have at least one digit. @@ -253,10 +257,6 @@ enum class parse_error { // fractional part. no_digits_in_fractional_part, #endif - // The mantissa must have at least one digit. - no_digits_in_mantissa, - // Scientific notation requires an exponential part. - missing_exponential_part, }; template struct parsed_number_string_t { @@ -301,15 +301,15 @@ parse_number_string(UC const *p, UC const *pend, #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN answer.negative = (*p == UC('-')); // C++17 20.19.3.(7.1) explicitly forbids '+' sign here - if ((*p == UC('-')) || - (uint64_t(options.format & chars_format::allow_leading_plus) && - !uint64_t(options.format & detail::basic_json_fmt) && *p == UC('+'))) { + if (*p == UC('-') || + (uint64_t(options.format & chars_format::allow_leading_plus) && + *p == UC('+'))) { ++p; if (p == pend) { return report_parse_error( - p, parse_error::missing_integer_or_dot_after_sign); + p, parse_error::missing_integer_or_dot_after_sign); } - if (uint64_t(options.format & detail::basic_json_fmt)) { + FASTFLOAT_IF_CONSTEXPR17(basic_json_fmt) { if (!is_integer(*p)) { // a sign must be followed by an integer return report_parse_error(p, parse_error::missing_integer_after_sign); diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index 554b7cf..42de867 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -225,7 +225,7 @@ from_chars_advanced(parsed_number_string_t const &pns, T &value) noexcept { // We could check it first (before the previous branch), but // there might be performance advantages at having the check // be last. - if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) { + FASTFLOAT_IF_CONSTEXPR17 (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) { // We have that fegetround() == FE_TONEAREST. // Next is Clinger's fast path. if (pns.mantissa <= binary_format::max_mantissa_fast_path()) {