mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-01-20 16:52:11 +00:00
Make sure cpp_int::eval_convert_to is noexcept as advertised.
Fixes #553.
This commit is contained in:
@@ -184,7 +184,7 @@ eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1,
|
||||
|
||||
template <class R, std::size_t MinBits1, std::size_t MaxBits1, cpp_integer_type SignType1, cpp_int_check_type Checked1, class Allocator1>
|
||||
inline BOOST_MP_CXX14_CONSTEXPR typename std::enable_if<std::is_floating_point<R>::value && !is_trivial_cpp_int<cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1> >::value, void>::type
|
||||
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) noexcept(boost::multiprecision::detail::is_arithmetic<R>::value)
|
||||
eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1, Checked1, Allocator1>& backend) noexcept(boost::multiprecision::detail::is_arithmetic<R>::value && std::numeric_limits<R>::has_infinity)
|
||||
{
|
||||
BOOST_MP_FLOAT128_USING using std::ldexp;
|
||||
if (eval_is_zero(backend))
|
||||
@@ -244,7 +244,15 @@ eval_convert_to(R* result, const cpp_int_backend<MinBits1, MaxBits1, SignType1,
|
||||
if ((eval_lsb_imp(backend) < static_cast<std::size_t>(bits)) || eval_bit_test(backend, static_cast<std::size_t>(bits + 1)))
|
||||
{
|
||||
#ifdef BOOST_MP_MATH_AVAILABLE
|
||||
*result = boost::math::float_next(*result);
|
||||
BOOST_IF_CONSTEXPR(std::numeric_limits<R>::has_infinity)
|
||||
{
|
||||
// Must NOT throw:
|
||||
*result = boost::math::float_next(*result, boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>()));
|
||||
}
|
||||
else
|
||||
{
|
||||
*result = boost::math::float_next(*result);
|
||||
}
|
||||
#else
|
||||
using std::nextafter; BOOST_MP_FLOAT128_USING
|
||||
*result = nextafter(*result, *result * 2);
|
||||
|
||||
Reference in New Issue
Block a user