mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
FASTFLOAT_IF_CONSTEXPR17
fix compilation when FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN isn't enabled.
This commit is contained in:
parent
1899647146
commit
e84f289337
@ -240,11 +240,15 @@ loop_parse_if_eight_digits(char const *&p, char const *const pend,
|
|||||||
|
|
||||||
enum class parse_error {
|
enum class parse_error {
|
||||||
no_error,
|
no_error,
|
||||||
|
// A sign must be followed by an integer or dot.
|
||||||
|
missing_integer_or_dot_after_sign,
|
||||||
|
// The mantissa must have at least one digit.
|
||||||
|
no_digits_in_mantissa,
|
||||||
|
// Scientific notation requires an exponential part.
|
||||||
|
missing_exponential_part,
|
||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
// [JSON-only] The minus sign must be followed by an integer.
|
// [JSON-only] The minus sign must be followed by an integer.
|
||||||
missing_integer_after_sign,
|
missing_integer_after_sign,
|
||||||
// A sign must be followed by an integer or dot.
|
|
||||||
missing_integer_or_dot_after_sign,
|
|
||||||
// [JSON-only] The integer part must not have leading zeros.
|
// [JSON-only] The integer part must not have leading zeros.
|
||||||
leading_zeros_in_integer_part,
|
leading_zeros_in_integer_part,
|
||||||
// [JSON-only] The integer part must have at least one digit.
|
// [JSON-only] The integer part must have at least one digit.
|
||||||
@ -253,10 +257,6 @@ enum class parse_error {
|
|||||||
// fractional part.
|
// fractional part.
|
||||||
no_digits_in_fractional_part,
|
no_digits_in_fractional_part,
|
||||||
#endif
|
#endif
|
||||||
// The mantissa must have at least one digit.
|
|
||||||
no_digits_in_mantissa,
|
|
||||||
// Scientific notation requires an exponential part.
|
|
||||||
missing_exponential_part,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename UC> struct parsed_number_string_t {
|
template <typename UC> struct parsed_number_string_t {
|
||||||
@ -301,15 +301,15 @@ parse_number_string(UC const *p, UC const *pend,
|
|||||||
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
#ifndef FASTFLOAT_ONLY_POSITIVE_C_NUMBER_WO_INF_NAN
|
||||||
answer.negative = (*p == UC('-'));
|
answer.negative = (*p == UC('-'));
|
||||||
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
// C++17 20.19.3.(7.1) explicitly forbids '+' sign here
|
||||||
if ((*p == UC('-')) ||
|
if (*p == UC('-') ||
|
||||||
(uint64_t(options.format & chars_format::allow_leading_plus) &&
|
(uint64_t(options.format & chars_format::allow_leading_plus) &&
|
||||||
!uint64_t(options.format & detail::basic_json_fmt) && *p == UC('+'))) {
|
*p == UC('+'))) {
|
||||||
++p;
|
++p;
|
||||||
if (p == pend) {
|
if (p == pend) {
|
||||||
return report_parse_error<UC>(
|
return report_parse_error<UC>(
|
||||||
p, parse_error::missing_integer_or_dot_after_sign);
|
p, parse_error::missing_integer_or_dot_after_sign);
|
||||||
}
|
}
|
||||||
if (uint64_t(options.format & detail::basic_json_fmt)) {
|
FASTFLOAT_IF_CONSTEXPR17(basic_json_fmt) {
|
||||||
if (!is_integer(*p)) { // a sign must be followed by an integer
|
if (!is_integer(*p)) { // a sign must be followed by an integer
|
||||||
return report_parse_error<UC>(p,
|
return report_parse_error<UC>(p,
|
||||||
parse_error::missing_integer_after_sign);
|
parse_error::missing_integer_after_sign);
|
||||||
|
|||||||
@ -225,7 +225,7 @@ from_chars_advanced(parsed_number_string_t<UC> const &pns, T &value) noexcept {
|
|||||||
// We could check it first (before the previous branch), but
|
// We could check it first (before the previous branch), but
|
||||||
// there might be performance advantages at having the check
|
// there might be performance advantages at having the check
|
||||||
// be last.
|
// be last.
|
||||||
if (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
|
FASTFLOAT_IF_CONSTEXPR17 (!cpp20_and_in_constexpr() && detail::rounds_to_nearest()) {
|
||||||
// We have that fegetround() == FE_TONEAREST.
|
// We have that fegetround() == FE_TONEAREST.
|
||||||
// Next is Clinger's fast path.
|
// Next is Clinger's fast path.
|
||||||
if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
|
if (pns.mantissa <= binary_format<T>::max_mantissa_fast_path()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user