remove out-of-line defns of constexpr static data members under c++17

Address warnings of this form under c++17 when building with `-Werror -Wdeprecated`:
```
fast_float/float_common.h:446:58: error: out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated [-Werror,-Wdeprecated]
constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[];
                                                         ^
```
This commit is contained in:
Yedidya Feldblum 2024-08-30 09:57:14 -05:00
parent f03b76f0e6
commit 159589d356
4 changed files with 30 additions and 0 deletions

View File

@ -404,12 +404,16 @@ template <typename = void> struct pow5_tables {
#endif #endif
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <typename T> constexpr uint32_t pow5_tables<T>::large_step; template <typename T> constexpr uint32_t pow5_tables<T>::large_step;
template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[]; template <typename T> constexpr uint64_t pow5_tables<T>::small_power_of_5[];
template <typename T> constexpr limb pow5_tables<T>::large_power_of_5[]; template <typename T> constexpr limb pow5_tables<T>::large_power_of_5[];
#endif
// big integer type. implements a small subset of big integer // big integer type. implements a small subset of big integer
// arithmetic, using simple algorithms since asymptotically // arithmetic, using simple algorithms since asymptotically
// faster algorithms are slower for a small number of limbs. // faster algorithms are slower for a small number of limbs.

View File

@ -37,4 +37,10 @@
#define FASTFLOAT_IS_CONSTEXPR 0 #define FASTFLOAT_IS_CONSTEXPR 0
#endif #endif
#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 0
#else
#define FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE 1
#endif
#endif // FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H #endif // FASTFLOAT_CONSTEXPR_FEATURE_DETECT_H

View File

@ -693,10 +693,14 @@ template <class unused = void> struct powers_template {
}; };
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <class unused> template <class unused>
constexpr uint64_t constexpr uint64_t
powers_template<unused>::power_of_five_128[number_of_entries]; powers_template<unused>::power_of_five_128[number_of_entries];
#endif
using powers = powers_template<>; using powers = powers_template<>;
} // namespace fast_float } // namespace fast_float

View File

@ -442,12 +442,16 @@ template <typename U> struct binary_format_lookup_tables<double, U> {
constant_55555 * 5 * 5 * 5 * 5)}; constant_55555 * 5 * 5 * 5 * 5)};
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <typename U> template <typename U>
constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[]; constexpr double binary_format_lookup_tables<double, U>::powers_of_ten[];
template <typename U> template <typename U>
constexpr uint64_t binary_format_lookup_tables<double, U>::max_mantissa[]; constexpr uint64_t binary_format_lookup_tables<double, U>::max_mantissa[];
#endif
template <typename U> struct binary_format_lookup_tables<float, U> { template <typename U> struct binary_format_lookup_tables<float, U> {
static constexpr float powers_of_ten[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f, static constexpr float powers_of_ten[] = {1e0f, 1e1f, 1e2f, 1e3f, 1e4f, 1e5f,
1e6f, 1e7f, 1e8f, 1e9f, 1e10f}; 1e6f, 1e7f, 1e8f, 1e9f, 1e10f};
@ -469,12 +473,16 @@ template <typename U> struct binary_format_lookup_tables<float, U> {
0x1000000 / (constant_55555 * constant_55555 * 5)}; 0x1000000 / (constant_55555 * constant_55555 * 5)};
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <typename U> template <typename U>
constexpr float binary_format_lookup_tables<float, U>::powers_of_ten[]; constexpr float binary_format_lookup_tables<float, U>::powers_of_ten[];
template <typename U> template <typename U>
constexpr uint64_t binary_format_lookup_tables<float, U>::max_mantissa[]; constexpr uint64_t binary_format_lookup_tables<float, U>::max_mantissa[];
#endif
template <> template <>
inline constexpr int binary_format<double>::min_exponent_fast_path() { inline constexpr int binary_format<double>::min_exponent_fast_path() {
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
@ -677,8 +685,12 @@ template <typename = void> struct space_lut {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <typename T> constexpr bool space_lut<T>::value[]; template <typename T> constexpr bool space_lut<T>::value[];
#endif
inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; } inline constexpr bool is_space(uint8_t c) { return space_lut<>::value[c]; }
#endif #endif
@ -759,12 +771,16 @@ template <typename = void> struct int_luts {
3379220508056640625, 4738381338321616896}; 3379220508056640625, 4738381338321616896};
}; };
#if FASTFLOAT_DETAIL_MUST_DEFINE_CONSTEXPR_VARIABLE
template <typename T> constexpr uint8_t int_luts<T>::chdigit[]; template <typename T> constexpr uint8_t int_luts<T>::chdigit[];
template <typename T> constexpr size_t int_luts<T>::maxdigits_u64[]; template <typename T> constexpr size_t int_luts<T>::maxdigits_u64[];
template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[]; template <typename T> constexpr uint64_t int_luts<T>::min_safe_u64[];
#endif
template <typename UC> template <typename UC>
fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) { fastfloat_really_inline constexpr uint8_t ch_to_digit(UC c) {
return int_luts<>::chdigit[static_cast<unsigned char>(c)]; return int_luts<>::chdigit[static_cast<unsigned char>(c)];