From 06e61729c95e4963a8b04983fd4bcb42a36c9534 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Tue, 1 Jun 2021 09:46:43 -0400 Subject: [PATCH] making constexpr as inline. --- include/fast_float/float_common.h | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/include/fast_float/float_common.h b/include/fast_float/float_common.h index 0368843..22b721d 100644 --- a/include/fast_float/float_common.h +++ b/include/fast_float/float_common.h @@ -210,68 +210,68 @@ constexpr static float powers_of_ten_float[] = {1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10}; template struct binary_format { - static constexpr int mantissa_explicit_bits(); - static constexpr int minimum_exponent(); - static constexpr int infinite_power(); - static constexpr int sign_index(); - static constexpr int min_exponent_fast_path(); - static constexpr int max_exponent_fast_path(); - static constexpr int max_exponent_round_to_even(); - static constexpr int min_exponent_round_to_even(); - static constexpr uint64_t max_mantissa_fast_path(); - static constexpr int largest_power_of_ten(); - static constexpr int smallest_power_of_ten(); - static constexpr T exact_power_of_ten(int64_t power); + static inline constexpr int mantissa_explicit_bits(); + static inline constexpr int minimum_exponent(); + static inline constexpr int infinite_power(); + static inline constexpr int sign_index(); + static inline constexpr int min_exponent_fast_path(); + static inline constexpr int max_exponent_fast_path(); + static inline constexpr int max_exponent_round_to_even(); + static inline constexpr int min_exponent_round_to_even(); + static inline constexpr uint64_t max_mantissa_fast_path(); + static inline constexpr int largest_power_of_ten(); + static inline constexpr int smallest_power_of_ten(); + static inline constexpr T exact_power_of_ten(int64_t power); }; -template <> constexpr int binary_format::mantissa_explicit_bits() { +template <> inline constexpr int binary_format::mantissa_explicit_bits() { return 52; } -template <> constexpr int binary_format::mantissa_explicit_bits() { +template <> inline constexpr int binary_format::mantissa_explicit_bits() { return 23; } -template <> constexpr int binary_format::max_exponent_round_to_even() { +template <> inline constexpr int binary_format::max_exponent_round_to_even() { return 23; } -template <> constexpr int binary_format::max_exponent_round_to_even() { +template <> inline constexpr int binary_format::max_exponent_round_to_even() { return 10; } -template <> constexpr int binary_format::min_exponent_round_to_even() { +template <> inline constexpr int binary_format::min_exponent_round_to_even() { return -4; } -template <> constexpr int binary_format::min_exponent_round_to_even() { +template <> inline constexpr int binary_format::min_exponent_round_to_even() { return -17; } -template <> constexpr int binary_format::minimum_exponent() { +template <> inline constexpr int binary_format::minimum_exponent() { return -1023; } -template <> constexpr int binary_format::minimum_exponent() { +template <> inline constexpr int binary_format::minimum_exponent() { return -127; } -template <> constexpr int binary_format::infinite_power() { +template <> inline constexpr int binary_format::infinite_power() { return 0x7FF; } -template <> constexpr int binary_format::infinite_power() { +template <> inline constexpr int binary_format::infinite_power() { return 0xFF; } -template <> constexpr int binary_format::sign_index() { return 63; } -template <> constexpr int binary_format::sign_index() { return 31; } +template <> inline constexpr int binary_format::sign_index() { return 63; } +template <> inline constexpr int binary_format::sign_index() { return 31; } -template <> constexpr int binary_format::min_exponent_fast_path() { +template <> inline constexpr int binary_format::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else return -22; #endif } -template <> constexpr int binary_format::min_exponent_fast_path() { +template <> inline constexpr int binary_format::min_exponent_fast_path() { #if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0) return 0; #else @@ -279,46 +279,46 @@ template <> constexpr int binary_format::min_exponent_fast_path() { #endif } -template <> constexpr int binary_format::max_exponent_fast_path() { +template <> inline constexpr int binary_format::max_exponent_fast_path() { return 22; } -template <> constexpr int binary_format::max_exponent_fast_path() { +template <> inline constexpr int binary_format::max_exponent_fast_path() { return 10; } -template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } -template <> constexpr uint64_t binary_format::max_mantissa_fast_path() { +template <> inline constexpr uint64_t binary_format::max_mantissa_fast_path() { return uint64_t(2) << mantissa_explicit_bits(); } template <> -constexpr double binary_format::exact_power_of_ten(int64_t power) { +inline constexpr double binary_format::exact_power_of_ten(int64_t power) { return powers_of_ten_double[power]; } template <> -constexpr float binary_format::exact_power_of_ten(int64_t power) { +inline constexpr float binary_format::exact_power_of_ten(int64_t power) { return powers_of_ten_float[power]; } template <> -constexpr int binary_format::largest_power_of_ten() { +inline constexpr int binary_format::largest_power_of_ten() { return 308; } template <> -constexpr int binary_format::largest_power_of_ten() { +inline constexpr int binary_format::largest_power_of_ten() { return 38; } template <> -constexpr int binary_format::smallest_power_of_ten() { +inline constexpr int binary_format::smallest_power_of_ten() { return -342; } template <> -constexpr int binary_format::smallest_power_of_ten() { +inline constexpr int binary_format::smallest_power_of_ten() { return -65; }