BREAKING CHANGE: Correct definition of user_rounding_error, (#836)

* BREAKING CHANGE: Correct definition of user_rounding_error,
To return correct type.
Likewise fix up a few other rounding error inconsistencies.
Fixes https://github.com/boostorg/math/issues/834.

* Remove redundant error handler.
This commit is contained in:
jzmaddock 2022-10-09 09:14:27 +01:00 committed by GitHub
parent ea9c3a27e9
commit ddf0143a8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 21 deletions

View File

@ -107,8 +107,8 @@ must be provided by the user:
template <class T>
T user_rounding_error(const char* function, const char* message, const T& val);
template <class T>
T user_evaluation_error(const char* function, const char* message, const T& val);
template <class T, class TargetType>
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
template <class T>
T user_indeterminate_result_error(const char* function, const char* message, const T& val);

View File

@ -39,7 +39,7 @@ boost/math/policies/error_handling.hpp like this:
template <class T>
T user_evaluation_error(const char* function, const char* message, const T& val);
template <class T, class TargetType>
T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
template <class T>
T user_indeterminate_result_error(const char* function, const char* message, const T& val);

View File

@ -74,7 +74,7 @@ T user_denorm_error(const char* function, const char* message, const T& val);
template <class T>
T user_evaluation_error(const char* function, const char* message, const T& val);
template <class T, class TargetType>
T user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
TargetType user_rounding_error(const char* function, const char* message, const T& val, const TargetType& t);
template <class T>
T user_indeterminate_result_error(const char* function, const char* message, const T& val);
@ -561,7 +561,7 @@ inline constexpr TargetType raise_rounding_error(
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be specialized.");
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must have std::numeric_limits specialized.");
return val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
}
@ -576,24 +576,9 @@ inline TargetType raise_rounding_error(
errno = ERANGE;
// This may or may not do the right thing, but the user asked for the error
// to be silent so here we go anyway:
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be specialized.");
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must have std::numeric_limits specialized.");
return val > 0 ? (std::numeric_limits<TargetType>::max)() : (std::numeric_limits<TargetType>::is_integer ? (std::numeric_limits<TargetType>::min)() : -(std::numeric_limits<TargetType>::max)());
}
template <class T>
inline T raise_rounding_error(
const char* ,
const char* ,
const T& val,
const T&,
const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T)
{
errno = ERANGE;
// This may or may not do the right thing, but the user asked for the error
// to be silent so here we go anyway:
return val > 0 ? boost::math::tools::max_value<T>() : -boost::math::tools::max_value<T>();
}
template <class T, class TargetType>
inline TargetType raise_rounding_error(
const char* function,