type usage fix

This commit is contained in:
IRainman 2025-05-07 00:44:20 +03:00
parent 2f8ff9a6eb
commit 4b94a612cf
3 changed files with 21 additions and 27 deletions

View File

@ -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<UC>(
@ -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) &&
(((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) &&
|| (((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<UC>(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;
}

View File

@ -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,14 +76,9 @@ using from_chars_result = from_chars_result_t<char>;
template <typename UC> 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;

View File

@ -33,7 +33,7 @@ from_chars_result_t<UC>
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<UC> 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<true, UC>(first, last, options)
:
#endif
@ -364,8 +364,7 @@ from_chars(UC const *first, UC const *last, T &value, int const base) noexcept {
static_assert(is_supported_char_type<UC>::value,
"only char, wchar_t, char16_t and char32_t are supported");
parse_options_t<UC> const options(
static_cast<chars_format_t>(chars_format::general), UC('.'),
parse_options_t<UC> const options(chars_format::general, UC('.'),
static_cast<uint_fast8_t>(base));
return from_chars_advanced(first, last, value, options);
}