Skip to content

Commit b3526da

Browse files
committed
uint64_t as enum base for chars_format
1 parent b8b5da7 commit b3526da

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

include/fast_float/ascii_number.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ parse_number_string(UC const *p, UC const *pend,
292292
answer.negative = (*p == UC('-'));
293293
#ifdef FASTFLOAT_ALLOWS_LEADING_PLUS // disabled by default
294294
if ((*p == UC('-')) ||
295-
(!int(fmt & detail::basic_json_fmt) && *p == UC('+'))) {
295+
(!uint64_t(fmt & detail::basic_json_fmt) && *p == UC('+'))) {
296296
#else
297297
if (*p == UC('-')) { // C++17 20.19.3.(7.1) explicitly forbids '+' sign here
298298
#endif
@@ -301,7 +301,7 @@ parse_number_string(UC const *p, UC const *pend,
301301
return report_parse_error<UC>(
302302
p, parse_error::missing_integer_or_dot_after_sign);
303303
}
304-
if (int(fmt & detail::basic_json_fmt)) {
304+
if (uint64_t(fmt & detail::basic_json_fmt)) {
305305
if (!is_integer(*p)) { // a sign must be followed by an integer
306306
return report_parse_error<UC>(p,
307307
parse_error::missing_integer_after_sign);
@@ -330,7 +330,7 @@ parse_number_string(UC const *p, UC const *pend,
330330
UC const *const end_of_integer_part = p;
331331
int64_t digit_count = int64_t(end_of_integer_part - start_digits);
332332
answer.integer = span<const UC>(start_digits, size_t(digit_count));
333-
if (int(fmt & detail::basic_json_fmt)) {
333+
if (uint64_t(fmt & detail::basic_json_fmt)) {
334334
// at least 1 digit in integer part, without leading zeros
335335
if (digit_count == 0) {
336336
return report_parse_error<UC>(p, parse_error::no_digits_in_integer_part);
@@ -359,7 +359,7 @@ parse_number_string(UC const *p, UC const *pend,
359359
answer.fraction = span<const UC>(before, size_t(p - before));
360360
digit_count -= exponent;
361361
}
362-
if (int(fmt & detail::basic_json_fmt)) {
362+
if (uint64_t(fmt & detail::basic_json_fmt)) {
363363
// at least 1 digit in fractional part
364364
if (has_decimal_point && exponent == 0) {
365365
return report_parse_error<UC>(p,
@@ -370,9 +370,9 @@ parse_number_string(UC const *p, UC const *pend,
370370
return report_parse_error<UC>(p, parse_error::no_digits_in_mantissa);
371371
}
372372
int64_t exp_number = 0; // explicit exponential part
373-
if ((int(fmt & chars_format::scientific) && (p != pend) &&
373+
if ((uint64_t(fmt & chars_format::scientific) && (p != pend) &&
374374
((UC('e') == *p) || (UC('E') == *p))) ||
375-
(int(fmt & detail::basic_fortran_fmt) && (p != pend) &&
375+
(uint64_t(fmt & detail::basic_fortran_fmt) && (p != pend) &&
376376
((UC('+') == *p) || (UC('-') == *p) || (UC('d') == *p) ||
377377
(UC('D') == *p)))) {
378378
UC const *location_of_e = p;
@@ -390,7 +390,7 @@ parse_number_string(UC const *p, UC const *pend,
390390
++p;
391391
}
392392
if ((p == pend) || !is_integer(*p)) {
393-
if (!int(fmt & chars_format::fixed)) {
393+
if (!uint64_t(fmt & chars_format::fixed)) {
394394
// The exponential part is invalid for scientific notation, so it must
395395
// be a trailing token for fixed notation. However, fixed notation is
396396
// disabled, so report a scientific notation error.
@@ -413,8 +413,8 @@ parse_number_string(UC const *p, UC const *pend,
413413
}
414414
} else {
415415
// If it scientific and not fixed, we have to bail out.
416-
if (int(fmt & chars_format::scientific) &&
417-
!int(fmt & chars_format::fixed)) {
416+
if (uint64_t(fmt & chars_format::scientific) &&
417+
!uint64_t(fmt & chars_format::fixed)) {
418418
return report_parse_error<UC>(p, parse_error::missing_exponential_part);
419419
}
420420
}

include/fast_float/float_common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717
namespace fast_float {
1818

19-
enum class chars_format;
19+
enum class chars_format : uint64_t;
2020

2121
namespace detail {
2222
constexpr chars_format basic_json_fmt = chars_format(1 << 5);
2323
constexpr chars_format basic_fortran_fmt = chars_format(1 << 6);
2424
} // namespace detail
2525

26-
enum class chars_format {
26+
enum class chars_format : uint64_t {
2727
scientific = 1 << 0,
2828
fixed = 1 << 2,
2929
hex = 1 << 3,
3030
no_infnan = 1 << 4,
3131
// RFC 8259: https://datatracker.ietf.org/doc/html/rfc8259#section-6
32-
json = int(detail::basic_json_fmt) | fixed | scientific | no_infnan,
32+
json = uint64_t(detail::basic_json_fmt) | fixed | scientific | no_infnan,
3333
// Extension of RFC 8259 where, e.g., "inf" and "nan" are allowed.
34-
json_or_infnan = int(detail::basic_json_fmt) | fixed | scientific,
35-
fortran = int(detail::basic_fortran_fmt) | fixed | scientific,
34+
json_or_infnan = uint64_t(detail::basic_json_fmt) | fixed | scientific,
35+
fortran = uint64_t(detail::basic_fortran_fmt) | fixed | scientific,
3636
general = fixed | scientific,
3737
};
3838

include/fast_float/parse_number.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ from_chars_advanced(UC const *first, UC const *last, T &value,
308308
parsed_number_string_t<UC> pns =
309309
parse_number_string<UC>(first, last, options);
310310
if (!pns.valid) {
311-
if (int(fmt & chars_format::no_infnan)) {
311+
if (uint64_t(fmt & chars_format::no_infnan)) {
312312
answer.ec = std::errc::invalid_argument;
313313
answer.ptr = first;
314314
return answer;

0 commit comments

Comments
 (0)