summaryrefslogtreecommitdiff
path: root/boost/math/policies/error_handling.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/math/policies/error_handling.hpp')
-rw-r--r--boost/math/policies/error_handling.hpp124
1 files changed, 72 insertions, 52 deletions
diff --git a/boost/math/policies/error_handling.hpp b/boost/math/policies/error_handling.hpp
index 674759006e..285fbea7c4 100644
--- a/boost/math/policies/error_handling.hpp
+++ b/boost/math/policies/error_handling.hpp
@@ -157,11 +157,11 @@ inline T raise_domain_error(
}
template <class T>
-inline T raise_domain_error(
+inline BOOST_MATH_CONSTEXPR T raise_domain_error(
const char* ,
const char* ,
const T& ,
- const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -173,7 +173,7 @@ inline T raise_domain_error(
const char* ,
const char* ,
const T& ,
- const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T)
{
errno = EDOM;
// This may or may not do the right thing, but the user asked for the error
@@ -202,21 +202,21 @@ inline T raise_pole_error(
}
template <class T>
-inline T raise_pole_error(
+inline BOOST_MATH_CONSTEXPR T raise_pole_error(
const char* function,
const char* message,
const T& val,
- const ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::pole_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>());
}
template <class T>
-inline T raise_pole_error(
+inline BOOST_MATH_CONSTEXPR T raise_pole_error(
const char* function,
const char* message,
const T& val,
- const ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::pole_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T)
{
return ::boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>());
}
@@ -256,10 +256,10 @@ inline T raise_overflow_error(
}
template <class T>
-inline T raise_overflow_error(
+inline BOOST_MATH_CONSTEXPR T raise_overflow_error(
const char* ,
const char* ,
- const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -267,11 +267,11 @@ inline T raise_overflow_error(
}
template <class T>
-inline T raise_overflow_error(
+inline BOOST_MATH_CONSTEXPR T raise_overflow_error(
const char* ,
const char* ,
const T&,
- const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -282,7 +282,7 @@ template <class T>
inline T raise_overflow_error(
const char* ,
const char* ,
- const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::overflow_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
@@ -295,7 +295,7 @@ inline T raise_overflow_error(
const char* ,
const char* ,
const T&,
- const ::boost::math::policies::overflow_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::overflow_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
@@ -342,10 +342,10 @@ inline T raise_underflow_error(
}
template <class T>
-inline T raise_underflow_error(
+inline BOOST_MATH_CONSTEXPR T raise_underflow_error(
const char* ,
const char* ,
- const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -356,7 +356,7 @@ template <class T>
inline T raise_underflow_error(
const char* /* function */,
const char* /* message */,
- const ::boost::math::policies::underflow_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::underflow_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
@@ -386,11 +386,11 @@ inline T raise_denorm_error(
}
template <class T>
-inline T raise_denorm_error(
+inline BOOST_MATH_CONSTEXPR T raise_denorm_error(
const char* ,
const char* ,
const T& val,
- const ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::denorm_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -402,7 +402,7 @@ inline T raise_denorm_error(
const char* ,
const char* ,
const T& val,
- const ::boost::math::policies::denorm_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::denorm_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
@@ -433,11 +433,11 @@ inline T raise_evaluation_error(
}
template <class T>
-inline T raise_evaluation_error(
+inline BOOST_MATH_CONSTEXPR T raise_evaluation_error(
const char* ,
const char* ,
const T& val,
- const ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::evaluation_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -449,7 +449,7 @@ inline T raise_evaluation_error(
const char* ,
const char* ,
const T& val,
- const ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&)
+ const ::boost::math::policies::evaluation_error< ::boost::math::policies::errno_on_error>&) BOOST_MATH_NOEXCEPT(T)
{
errno = EDOM;
// This may or may not do the right thing, but the user asked for the error
@@ -481,12 +481,12 @@ inline TargetType raise_rounding_error(
}
template <class T, class TargetType>
-inline TargetType raise_rounding_error(
+inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error(
const char* ,
const char* ,
const T& val,
const TargetType&,
- const ::boost::math::policies::rounding_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::rounding_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -500,7 +500,7 @@ inline TargetType raise_rounding_error(
const char* ,
const T& val,
const TargetType&,
- const ::boost::math::policies::rounding_error< ::boost::math::policies::errno_on_error>&)
+ 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
@@ -509,6 +509,20 @@ inline TargetType raise_rounding_error(
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,
@@ -534,12 +548,12 @@ inline T raise_indeterminate_result_error(
}
template <class T, class R>
-inline T raise_indeterminate_result_error(
+inline BOOST_MATH_CONSTEXPR T raise_indeterminate_result_error(
const char* ,
const char* ,
const T& ,
const R& result,
- const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::ignore_error>&)
+ const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
{
// This may or may not do the right thing, but the user asked for the error
// to be ignored so here we go anyway:
@@ -574,7 +588,7 @@ inline T raise_indeterminate_result_error(
} // namespace detail
template <class T, class Policy>
-inline T raise_domain_error(const char* function, const char* message, const T& val, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_domain_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::domain_error_type policy_type;
return detail::raise_domain_error(
@@ -583,7 +597,7 @@ inline T raise_domain_error(const char* function, const char* message, const T&
}
template <class T, class Policy>
-inline T raise_pole_error(const char* function, const char* message, const T& val, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_pole_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::pole_error_type policy_type;
return detail::raise_pole_error(
@@ -592,7 +606,7 @@ inline T raise_pole_error(const char* function, const char* message, const T& va
}
template <class T, class Policy>
-inline T raise_overflow_error(const char* function, const char* message, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const char* message, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::overflow_error_type policy_type;
return detail::raise_overflow_error<T>(
@@ -601,7 +615,7 @@ inline T raise_overflow_error(const char* function, const char* message, const P
}
template <class T, class Policy>
-inline T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::overflow_error_type policy_type;
return detail::raise_overflow_error(
@@ -610,7 +624,7 @@ inline T raise_overflow_error(const char* function, const char* message, const T
}
template <class T, class Policy>
-inline T raise_underflow_error(const char* function, const char* message, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_underflow_error(const char* function, const char* message, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::underflow_error_type policy_type;
return detail::raise_underflow_error<T>(
@@ -619,7 +633,7 @@ inline T raise_underflow_error(const char* function, const char* message, const
}
template <class T, class Policy>
-inline T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::denorm_error_type policy_type;
return detail::raise_denorm_error<T>(
@@ -629,7 +643,7 @@ inline T raise_denorm_error(const char* function, const char* message, const T&
}
template <class T, class Policy>
-inline T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::evaluation_error_type policy_type;
return detail::raise_evaluation_error(
@@ -638,7 +652,7 @@ inline T raise_evaluation_error(const char* function, const char* message, const
}
template <class T, class TargetType, class Policy>
-inline TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&)
+inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::rounding_error_type policy_type;
return detail::raise_rounding_error(
@@ -647,7 +661,7 @@ inline TargetType raise_rounding_error(const char* function, const char* message
}
template <class T, class R, class Policy>
-inline T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&)
+inline BOOST_MATH_CONSTEXPR T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&) BOOST_NOEXCEPT_IF(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
{
typedef typename Policy::indeterminate_result_error_type policy_type;
return detail::raise_indeterminate_result_error(
@@ -662,7 +676,7 @@ namespace detail
{
template <class R, class T, class Policy>
-inline bool check_overflow(T val, R* result, const char* function, const Policy& pol)
+inline bool check_overflow(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
BOOST_MATH_STD_USING
if(fabs(val) > tools::max_value<R>())
@@ -674,7 +688,7 @@ inline bool check_overflow(T val, R* result, const char* function, const Policy&
return false;
}
template <class R, class T, class Policy>
-inline bool check_overflow(std::complex<T> val, R* result, const char* function, const Policy& pol)
+inline bool check_overflow(std::complex<T> val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
typedef typename R::value_type r_type;
r_type re, im;
@@ -684,7 +698,7 @@ inline bool check_overflow(std::complex<T> val, R* result, const char* function,
return r;
}
template <class R, class T, class Policy>
-inline bool check_underflow(T val, R* result, const char* function, const Policy& pol)
+inline bool check_underflow(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
if((val != 0) && (static_cast<R>(val) == 0))
{
@@ -694,7 +708,7 @@ inline bool check_underflow(T val, R* result, const char* function, const Policy
return false;
}
template <class R, class T, class Policy>
-inline bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol)
+inline bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
typedef typename R::value_type r_type;
r_type re, im;
@@ -704,7 +718,7 @@ inline bool check_underflow(std::complex<T> val, R* result, const char* function
return r;
}
template <class R, class T, class Policy>
-inline bool check_denorm(T val, R* result, const char* function, const Policy& pol)
+inline bool check_denorm(T val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
BOOST_MATH_STD_USING
if((fabs(val) < static_cast<T>(tools::min_value<R>())) && (static_cast<R>(val) != 0))
@@ -715,7 +729,7 @@ inline bool check_denorm(T val, R* result, const char* function, const Policy& p
return false;
}
template <class R, class T, class Policy>
-inline bool check_denorm(std::complex<T> val, R* result, const char* function, const Policy& pol)
+inline bool check_denorm(std::complex<T> val, R* result, const char* function, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
{
typedef typename R::value_type r_type;
r_type re, im;
@@ -727,22 +741,28 @@ inline bool check_denorm(std::complex<T> val, R* result, const char* function, c
// Default instantiations with ignore_error policy.
template <class R, class T>
-inline bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
template <class R, class T>
-inline bool check_overflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_overflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
template <class R, class T>
-inline bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
template <class R, class T>
-inline bool check_underflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_underflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
template <class R, class T>
-inline bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
template <class R, class T>
-inline bool check_denorm(std::complex<T> /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&){ return false; }
+inline BOOST_MATH_CONSTEXPR bool check_denorm(std::complex<T> /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
+{ return false; }
} // namespace detail
template <class R, class Policy, class T>
-inline R checked_narrowing_cast(T val, const char* function)
+inline R checked_narrowing_cast(T val, const char* function) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
{
typedef typename Policy::overflow_error_type overflow_type;
typedef typename Policy::underflow_error_type underflow_type;
@@ -762,7 +782,7 @@ inline R checked_narrowing_cast(T val, const char* function)
}
template <class T, class Policy>
-inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
+inline void check_series_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
{
if(max_iter >= policies::get_max_series_iterations<Policy>())
raise_evaluation_error<T>(
@@ -771,7 +791,7 @@ inline void check_series_iterations(const char* function, boost::uintmax_t max_i
}
template <class T, class Policy>
-inline void check_root_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol)
+inline void check_root_iterations(const char* function, boost::uintmax_t max_iter, const Policy& pol) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
{
if(max_iter >= policies::get_max_root_iterations<Policy>())
raise_evaluation_error<T>(
@@ -788,7 +808,7 @@ namespace detail{
// that value usually comes from one of the error handlers above:
//
template <class T>
-std::pair<T, T> pair_from_single(const T& val)
+std::pair<T, T> pair_from_single(const T& val) BOOST_MATH_NOEXCEPT(T)
{
return std::make_pair(val, val);
}