@@ -279,7 +279,7 @@ report_parse_error(UC const *p, parse_error error) {
279
279
280
280
// Assuming that you use no more than 19 digits, this will
281
281
// parse an ASCII string.
282
- template <typename UC>
282
+ template <bool basic_json_fmt, typename UC>
283
283
fastfloat_really_inline FASTFLOAT_CONSTEXPR20 parsed_number_string_t <UC>
284
284
parse_number_string (UC const *p, UC const *pend,
285
285
parse_options_t <UC> options) noexcept {
@@ -292,20 +292,20 @@ parse_number_string(UC const *p, UC const *pend,
292
292
// assume p < pend, so dereference without checks;
293
293
answer.negative = (*p == UC (' -' ));
294
294
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
295
- if ((*p == UC (' -' )) ||
296
- (uint64_t (fmt & chars_format::allow_leading_plus) &&
297
- !uint64_t (fmt & detail::basic_json_fmt) && *p == UC (' +' ))) {
295
+ if ((*p == UC (' -' )) || (uint64_t (fmt & chars_format::allow_leading_plus) &&
296
+ !basic_json_fmt && *p == UC (' +' ))) {
298
297
++p;
299
298
if (p == pend) {
300
299
return report_parse_error<UC>(
301
300
p, parse_error::missing_integer_or_dot_after_sign);
302
301
}
303
- if ( uint64_t (fmt & detail:: basic_json_fmt) ) {
302
+ FASTFLOAT_IF_CONSTEXPR17 ( basic_json_fmt) {
304
303
if (!is_integer (*p)) { // a sign must be followed by an integer
305
304
return report_parse_error<UC>(p,
306
305
parse_error::missing_integer_after_sign);
307
306
}
308
- } else {
307
+ }
308
+ else {
309
309
if (!is_integer (*p) &&
310
310
(*p !=
311
311
decimal_point)) { // a sign must be followed by an integer or the dot
@@ -329,7 +329,7 @@ parse_number_string(UC const *p, UC const *pend,
329
329
UC const *const end_of_integer_part = p;
330
330
int64_t digit_count = int64_t (end_of_integer_part - start_digits);
331
331
answer.integer = span<UC const >(start_digits, size_t (digit_count));
332
- if ( uint64_t (fmt & detail:: basic_json_fmt) ) {
332
+ FASTFLOAT_IF_CONSTEXPR17 ( basic_json_fmt) {
333
333
// at least 1 digit in integer part, without leading zeros
334
334
if (digit_count == 0 ) {
335
335
return report_parse_error<UC>(p, parse_error::no_digits_in_integer_part);
@@ -358,14 +358,14 @@ parse_number_string(UC const *p, UC const *pend,
358
358
answer.fraction = span<UC const >(before, size_t (p - before));
359
359
digit_count -= exponent;
360
360
}
361
- if ( uint64_t (fmt & detail:: basic_json_fmt) ) {
361
+ FASTFLOAT_IF_CONSTEXPR17 ( basic_json_fmt) {
362
362
// at least 1 digit in fractional part
363
363
if (has_decimal_point && exponent == 0 ) {
364
364
return report_parse_error<UC>(p,
365
365
parse_error::no_digits_in_fractional_part);
366
366
}
367
- } else if (digit_count ==
368
- 0 ) { // we must have encountered at least one integer!
367
+ }
368
+ else if (digit_count == 0 ) { // we must have encountered at least one integer!
369
369
return report_parse_error<UC>(p, parse_error::no_digits_in_mantissa);
370
370
}
371
371
int64_t exp_number = 0 ; // explicit exponential part
0 commit comments