Skip to content

Commit 5bc9637

Browse files
committed
type usage fixes.
fix for FASTFLOAT_ISNOT_CHECKED_BOUNDS if FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN isn't enabled.
1 parent 59c873d commit 5bc9637

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

include/fast_float/fast_float.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ template <typename T, typename UC = char,
8888
typename = FASTFLOAT_ENABLE_IF(is_supported_integer_type<T>::value)>
8989
FASTFLOAT_CONSTEXPR20 from_chars_result_t<UC>
9090
from_chars(UC const *first, UC const *last, T &value,
91-
uint_fast8_t const base = 10) noexcept;
91+
base_t const base = 10) noexcept;
9292

9393
} // namespace fast_float
9494

include/fast_float/parse_number.h

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -336,11 +336,13 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
336336
++first;
337337
}
338338
}
339-
#endif
339+
#else
340340
#ifdef FASTFLOAT_ISNOT_CHECKED_BOUNDS
341341
// We are in parser code with external loop that checks bounds.
342342
FASTFLOAT_ASSUME(first < last);
343-
#else
343+
#endif
344+
#endif
345+
#ifndef FASTFLOAT_ISNOT_CHECKED_BOUNDS
344346
if (first == last) {
345347
answer.ec = std::errc::invalid_argument;
346348
answer.ptr = first;
@@ -414,13 +416,12 @@ FASTFLOAT_CONSTEXPR20
414416
typename std::enable_if<is_supported_float_type<T>::value, T>::type
415417
integer_times_pow10(am_sign_mant_t const mantissa,
416418
am_pow_t const decimal_exponent) noexcept {
417-
#ifdef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
418-
FASTFLOAT_ASSUME(mantissa >= 0);
419-
const am_mant_t m = static_cast<am_mant_t>(mantissa);
420-
#else
419+
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
421420
const bool is_negative = mantissa < 0;
422-
const am_mant_t m =
423-
static_cast<am_mant_t>(is_negative ? -mantissa : mantissa);
421+
const auto m = static_cast<am_mant_t>(is_negative ? -mantissa : mantissa);
422+
#else
423+
FASTFLOAT_ASSUME(mantissa >= 0);
424+
const auto m = static_cast<am_mant_t>(mantissa);
424425
#endif
425426
T value;
426427
if (clinger_fast_path_impl(m, decimal_exponent,
@@ -460,7 +461,8 @@ FASTFLOAT_CONSTEXPR20
460461
std::is_integral<Int>::value &&
461462
!std::is_signed<Int>::value,
462463
T>::type
463-
integer_times_pow10(Int mantissa, am_pow_t decimal_exponent) noexcept {
464+
integer_times_pow10(Int const mantissa,
465+
am_pow_t const decimal_exponent) noexcept {
464466
return integer_times_pow10<T>(static_cast<am_mant_t>(mantissa),
465467
decimal_exponent);
466468
}
@@ -471,23 +473,26 @@ FASTFLOAT_CONSTEXPR20
471473
std::is_integral<Int>::value &&
472474
std::is_signed<Int>::value,
473475
T>::type
474-
integer_times_pow10(Int mantissa, am_pow_t decimal_exponent) noexcept {
476+
integer_times_pow10(Int const mantissa,
477+
am_pow_t const decimal_exponent) noexcept {
475478
return integer_times_pow10<T>(static_cast<am_sign_mant_t>(mantissa),
476479
decimal_exponent);
477480
}
478481

479482
template <typename Int>
480483
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
481484
std::is_integral<Int>::value && !std::is_signed<Int>::value, double>::type
482-
integer_times_pow10(Int mantissa, am_pow_t decimal_exponent) noexcept {
485+
integer_times_pow10(Int const mantissa,
486+
am_pow_t const decimal_exponent) noexcept {
483487
return integer_times_pow10(static_cast<am_mant_t>(mantissa),
484488
decimal_exponent);
485489
}
486490

487491
template <typename Int>
488492
FASTFLOAT_CONSTEXPR20 typename std::enable_if<
489493
std::is_integral<Int>::value && std::is_signed<Int>::value, double>::type
490-
integer_times_pow10(Int mantissa, am_pow_t decimal_exponent) noexcept {
494+
integer_times_pow10(Int const mantissa,
495+
am_pow_t const decimal_exponent) noexcept {
491496
return integer_times_pow10(static_cast<am_sign_mant_t>(mantissa),
492497
decimal_exponent);
493498
}
@@ -508,10 +513,11 @@ from_chars_int_advanced(UC const *first, UC const *last, T &value,
508513
++first;
509514
}
510515
}
511-
#endif
516+
#else
512517
#ifdef FASTFLOAT_ISNOT_CHECKED_BOUNDS
513518
// We are in parser code with external loop that checks bounds.
514519
FASTFLOAT_ASSUME(first < last);
520+
#endif
515521
#endif
516522
if (
517523
#ifndef FASTFLOAT_ISNOT_CHECKED_BOUNDS

0 commit comments

Comments
 (0)