Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAKING CHANGE: Correct definition of user_rounding_error, #836

Merged
merged 2 commits into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/policies/policy.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion example/policy_eg_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
21 changes: 3 additions & 18 deletions include/boost/math/policies/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)());
}

Expand All @@ -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,
Expand Down