Remove some constexpr reqs for old GCC

This commit is contained in:
ckormanyos
2025-08-30 16:14:32 +02:00
parent 324cc5f12f
commit a26871b55a
2 changed files with 68 additions and 12 deletions
+59 -11
View File
@@ -1053,7 +1053,47 @@ class cpp_double_fp_backend
return cpp_double_fp_backend(static_cast<float_type>(HUGE_VAL), float_type { 0.0F }); // conversion from double infinity OK
}
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
static auto my_value_logmax() noexcept -> const cpp_double_fp_backend&
#else
static constexpr auto my_value_logmax() noexcept -> cpp_double_fp_backend
#endif
{
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
static const cpp_double_fp_backend my_value_logmax_constexpr = my_value_logmax_maker();
#else
constexpr cpp_double_fp_backend my_value_logmax_constexpr = my_value_logmax_maker();
#endif
return my_value_logmax_constexpr;
}
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
static auto my_value_logmin() noexcept -> const cpp_double_fp_backend&
#else
static constexpr auto my_value_logmin() noexcept -> cpp_double_fp_backend
#endif
{
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
static const cpp_double_fp_backend my_value_logmin_constexpr = my_value_logmin_maker();
#else
constexpr cpp_double_fp_backend my_value_logmin_constexpr = my_value_logmin_maker();
#endif
return my_value_logmin_constexpr;
}
private:
rep_type data;
using cpp_bin_float_read_write_backend_type = boost::multiprecision::backends::cpp_bin_float<static_cast<unsigned>(my_digits), digit_base_2, void, int, cpp_df_qf_detail::ccmath::numeric_limits<float_type>::min_exponent, cpp_df_qf_detail::ccmath::numeric_limits<float_type>::max_exponent>;
using cpp_bin_float_read_write_exp_type = typename cpp_bin_float_read_write_backend_type::exponent_type;
using cpp_bin_float_read_write_type = boost::multiprecision::number<cpp_bin_float_read_write_backend_type, boost::multiprecision::et_off>;
auto rd_string(const char* pstr) -> bool;
static constexpr auto my_value_logmax_maker() noexcept -> cpp_double_fp_backend
{
// Here, we note that max is composed of (first + second),
// which we refactor as first * (1 + second / first).
@@ -1092,10 +1132,19 @@ class cpp_double_fp_backend
#endif
);
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
#else
static_assert
(
eval_gt(my_value_logmax_constexpr, cpp_double_fp_backend(1)),
"Error: logmax value is definitely incorrect"
);
#endif
return my_value_logmax_constexpr;
}
static constexpr auto my_value_logmin() noexcept -> cpp_double_fp_backend
static constexpr auto my_value_logmin_maker() noexcept -> cpp_double_fp_backend
{
// Here, we note that min is composed of (first + second),
// which we refactor as first * (1 + second / first).
@@ -1128,19 +1177,18 @@ class cpp_double_fp_backend
#endif
);
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
#else
static_assert
(
eval_lt(my_value_logmin_constexpr, cpp_double_fp_backend(-1)),
"Error: logmin value is definitely incorrect"
);
#endif
return my_value_logmin_constexpr;
}
private:
rep_type data;
using cpp_bin_float_read_write_backend_type = boost::multiprecision::backends::cpp_bin_float<static_cast<unsigned>(my_digits), digit_base_2, void, int, cpp_df_qf_detail::ccmath::numeric_limits<float_type>::min_exponent, cpp_df_qf_detail::ccmath::numeric_limits<float_type>::max_exponent>;
using cpp_bin_float_read_write_exp_type = typename cpp_bin_float_read_write_backend_type::exponent_type;
using cpp_bin_float_read_write_type = boost::multiprecision::number<cpp_bin_float_read_write_backend_type, boost::multiprecision::et_off>;
auto rd_string(const char* pstr) -> bool;
constexpr auto mul_unchecked(const cpp_double_fp_backend& v) -> void
{
// The multiplication algorithm has been taken from Victor Shoup,
+9 -1
View File
@@ -29,12 +29,20 @@ void test_constexpr_ness()
constexpr cpp_double_double dd_s { sqrt(dd_a) };
constexpr cpp_double_double sqrt_hundred { sqrt(cpp_double_double(100)) };
constexpr cpp_double_double log_hundred { log(cpp_double_double(100)) };
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
const
#else
constexpr
#endif
cpp_double_double log_hundred { log(cpp_double_double(100)) };
static_assert(dd_c > 5, "Error in constexpr multiplication");
static_assert(dd_s > 1, "Error in constexpr square root");
static_assert(sqrt_hundred == 10, "Error in constexpr square root");
#if (defined(BOOST_GCC) && !defined(BOOST_CLANG) && (BOOST_GCC < 80000))
#else
static_assert(log_hundred > 4.605, "Error in constexpr logarithm");
#endif
BOOST_CHECK(dd_c > 5);
BOOST_CHECK(dd_s > 1);