diff --git a/include/fast_float/ascii_number.h b/include/fast_float/ascii_number.h index bc44912..144ca59 100644 --- a/include/fast_float/ascii_number.h +++ b/include/fast_float/ascii_number.h @@ -303,8 +303,8 @@ parse_number_string(UC const *p, UC const *pend, answer.negative = (*p == UC('-')); // C++17 20.19.3.(7.1) explicitly forbids '+' sign here if ((*p == UC('-')) || - (chars_format_t(options.format & chars_format::allow_leading_plus) && - !basic_json_fmt && *p == UC('+'))) { + ((chars_format_t(options.format & chars_format::allow_leading_plus)) && + (!basic_json_fmt && *p == UC('+')))) { ++p; if (p == pend) { return report_parse_error( @@ -393,14 +393,14 @@ parse_number_string(UC const *p, UC const *pend, // Now we can parse the explicit exponential part. am_pow_t exp_number = 0; // explicit exponential part if (((p != pend) && - (((chars_format_t(options.format & chars_format::scientific) && - ((UC('e') == *p) || (UC('E') == *p)))) + (((chars_format_t(options.format & chars_format::scientific)) && + ((UC('e') == *p) || (UC('E') == *p)))) #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - || (chars_format_t(options.format & detail::basic_fortran_fmt) && - ((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) || - (UC('D') == *p))) + || (((chars_format_t(options.format & detail::basic_fortran_fmt))) && + ((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) || + (UC('D') == *p))) #endif - ))) { + )) { UC const *location_of_e = p; #ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN ++p; @@ -421,7 +421,7 @@ parse_number_string(UC const *p, UC const *pend, } } if ((p == pend) || !is_integer(*p)) { - if (!chars_format_t(options.format & chars_format::fixed)) { + if (!(chars_format_t(options.format & chars_format::fixed))) { // The exponential part is invalid for scientific notation, so it // must be a trailing token for fixed notation. However, fixed // notation is disabled, so report a scientific notation error. @@ -445,8 +445,8 @@ parse_number_string(UC const *p, UC const *pend, } } else { // If it scientific and not fixed, we have to bail out. - if (chars_format_t(options.format & chars_format::scientific) && - !chars_format_t(options.format & chars_format::fixed)) { + if ((chars_format_t(options.format & chars_format::scientific)) && + !(chars_format_t(options.format & chars_format::fixed))) { return report_parse_error(p, parse_error::missing_exponential_part); } } @@ -531,7 +531,7 @@ parse_int_string(UC const *p, UC const *pend, T &value, return answer; } if ((*p == UC('-')) || - (chars_format_t(options.format & chars_format::allow_leading_plus) && + ((chars_format_t(options.format & chars_format::allow_leading_plus)) && (*p == UC('+')))) { ++p; } diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 37e0ec8..378ce22 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -58,7 +58,7 @@ enum class chars_format : chars_format_t { #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN no_infnan = 1 << 3, // RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6 - json = uint64_t(detail::basic_json_fmt) | general | no_infnan, + json = chars_format_t(detail::basic_json_fmt) | general | no_infnan, // Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed. json_or_infnan = chars_format_t(detail::basic_json_fmt) | general, fortran = chars_format_t(detail::basic_fortran_fmt) | general, @@ -76,17 +76,12 @@ using from_chars_result = from_chars_result_t; template struct parse_options_t { constexpr explicit parse_options_t( - chars_format_t const fmt = chars_format::general, UC const dot = UC('.'), + chars_format const fmt = chars_format::general, UC const dot = UC('.'), uint_fast8_t const b = 10) noexcept - : format(fmt), decimal_point(dot), - base(b){ -#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - // static_assert(b >= 2 && b <= 36); -#endif - } + : format(fmt), decimal_point(dot), base(b) {} - /** Which number formats are accepted */ - chars_format format; + /** Which number formats are accepted */ + chars_format format; /** The character used as decimal point */ UC decimal_point; /** The base used for integers */ diff --git a/include/fast_float/parse_number.h b/include/fast_float/parse_number.h index b764540..df079ba 100644 --- a/include/fast_float/parse_number.h +++ b/include/fast_float/parse_number.h @@ -33,7 +33,7 @@ from_chars_result_t bool const minusSign = (*first == UC('-')); // C++17 20.19.3.(7.1) explicitly forbids '+' sign here if ((*first == UC('-')) || - (chars_format_t(fmt & chars_format::allow_leading_plus) && + ((chars_format_t(fmt & chars_format::allow_leading_plus)) && (*first == UC('+')))) { ++first; } @@ -332,7 +332,7 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value, #endif parsed_number_string_t const pns = #ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN - chars_format_t(options.format & detail::basic_json_fmt) + (chars_format_t(options.format & detail::basic_json_fmt)) ? parse_number_string(first, last, options) : #endif @@ -364,9 +364,8 @@ from_chars(UC const *first, UC const *last, T &value, int const base) noexcept { static_assert(is_supported_char_type::value, "only char, wchar_t, char16_t and char32_t are supported"); - parse_options_t const options( - static_cast(chars_format::general), UC('.'), - static_cast(base)); + parse_options_t const options(chars_format::general, UC('.'), + static_cast(base)); return from_chars_advanced(first, last, value, options); }