update boost
This commit is contained in:
@@ -8,21 +8,25 @@
|
||||
#ifndef BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
#define BOOST_MATH_POLICY_ERROR_HANDLING_HPP
|
||||
|
||||
#include <stdexcept>
|
||||
#include <boost/math/tools/config.hpp>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#ifndef BOOST_NO_RTTI
|
||||
#include <typeinfo>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <boost/config/no_tr1/complex.hpp>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
#include <stdexcept>
|
||||
#include <boost/math/tools/config.hpp>
|
||||
#include <complex>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <boost/math/policies/policy.hpp>
|
||||
#include <boost/math/tools/precision.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#include <stdexcept>
|
||||
#include <boost/math/tools/throw_exception.hpp>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push) // Quiet warnings in boost/format.hpp
|
||||
# pragma warning(disable: 4996) // _SCL_SECURE_NO_DEPRECATE
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated.
|
||||
@@ -36,18 +40,22 @@
|
||||
|
||||
namespace boost{ namespace math{
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
|
||||
class evaluation_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
evaluation_error(const std::string& s) : std::runtime_error(s){}
|
||||
explicit evaluation_error(const std::string& s) : std::runtime_error(s){}
|
||||
};
|
||||
|
||||
class rounding_error : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
rounding_error(const std::string& s) : std::runtime_error(s){}
|
||||
explicit rounding_error(const std::string& s) : std::runtime_error(s){}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
namespace policies{
|
||||
//
|
||||
// Forward declarations of user error handlers,
|
||||
@@ -66,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);
|
||||
|
||||
@@ -74,7 +82,7 @@ namespace detail
|
||||
{
|
||||
|
||||
template <class T>
|
||||
std::string prec_format(const T& val)
|
||||
inline std::string prec_format(const T& val)
|
||||
{
|
||||
typedef typename boost::math::policies::precision<T, boost::math::policies::policy<> >::type prec_type;
|
||||
std::stringstream ss;
|
||||
@@ -87,6 +95,18 @@ std::string prec_format(const T& val)
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
#ifdef BOOST_MATH_USE_CHARCONV_FOR_CONVERSION
|
||||
|
||||
template <>
|
||||
inline std::string prec_format<std::float128_t>(const std::float128_t& val)
|
||||
{
|
||||
char buffer[128] {};
|
||||
const auto r = std::to_chars(buffer, buffer + sizeof(buffer), val);
|
||||
return std::string(buffer, r.ptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
inline void replace_all_in_string(std::string& result, const char* what, const char* with)
|
||||
{
|
||||
std::string::size_type pos = 0;
|
||||
@@ -120,13 +140,18 @@ inline const char* name_of<BOOST_MATH_FLOAT128_TYPE>()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
template <class E, class T>
|
||||
void raise_error(const char* pfunction, const char* message)
|
||||
{
|
||||
if(pfunction == 0)
|
||||
if(pfunction == nullptr)
|
||||
{
|
||||
pfunction = "Unknown function operating on type %1%";
|
||||
if(message == 0)
|
||||
}
|
||||
if(message == nullptr)
|
||||
{
|
||||
message = "Cause unknown";
|
||||
}
|
||||
|
||||
std::string function(pfunction);
|
||||
std::string msg("Error in function ");
|
||||
@@ -139,17 +164,20 @@ void raise_error(const char* pfunction, const char* message)
|
||||
msg += ": ";
|
||||
msg += message;
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
BOOST_MATH_THROW_EXCEPTION(E(msg))
|
||||
}
|
||||
|
||||
template <class E, class T>
|
||||
void raise_error(const char* pfunction, const char* pmessage, const T& val)
|
||||
{
|
||||
if(pfunction == 0)
|
||||
if(pfunction == nullptr)
|
||||
{
|
||||
pfunction = "Unknown function operating on type %1%";
|
||||
if(pmessage == 0)
|
||||
}
|
||||
if(pmessage == nullptr)
|
||||
{
|
||||
pmessage = "Cause unknown: error caused by bad argument with value %1%";
|
||||
}
|
||||
|
||||
std::string function(pfunction);
|
||||
std::string message(pmessage);
|
||||
@@ -166,9 +194,9 @@ void raise_error(const char* pfunction, const char* pmessage, const T& val)
|
||||
replace_all_in_string(message, "%1%", sval.c_str());
|
||||
msg += message;
|
||||
|
||||
E e(msg);
|
||||
boost::throw_exception(e);
|
||||
BOOST_MATH_THROW_EXCEPTION(E(msg))
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
inline T raise_domain_error(
|
||||
@@ -177,13 +205,17 @@ inline T raise_domain_error(
|
||||
const T& val,
|
||||
const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::domain_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_domain_error(
|
||||
inline constexpr T raise_domain_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
@@ -224,11 +256,15 @@ inline T raise_pole_error(
|
||||
const T& val,
|
||||
const ::boost::math::policies::pole_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
return boost::math::policies::detail::raise_domain_error(function, message, val, ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>());
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_pole_error(
|
||||
inline constexpr T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
@@ -238,7 +274,7 @@ inline BOOST_MATH_CONSTEXPR T raise_pole_error(
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_pole_error(
|
||||
inline constexpr T raise_pole_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const T& val,
|
||||
@@ -257,16 +293,19 @@ inline T raise_pole_error(
|
||||
return user_pole_error(function, message, val);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
inline T raise_overflow_error(
|
||||
const char* function,
|
||||
const char* message,
|
||||
const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow");
|
||||
// We should never get here:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -276,13 +315,17 @@ inline T raise_overflow_error(
|
||||
const T& val,
|
||||
const ::boost::math::policies::overflow_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::overflow_error, T>(function, message ? message : "numeric overflow", val);
|
||||
// We should never get here:
|
||||
return std::numeric_limits<T>::has_infinity ? std::numeric_limits<T>::infinity() : boost::math::tools::max_value<T>();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_overflow_error(
|
||||
inline constexpr T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policies::overflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
|
||||
@@ -293,7 +336,7 @@ inline BOOST_MATH_CONSTEXPR T raise_overflow_error(
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_overflow_error(
|
||||
inline constexpr T raise_overflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T&,
|
||||
@@ -358,13 +401,17 @@ inline T raise_underflow_error(
|
||||
const char* message,
|
||||
const ::boost::math::policies::underflow_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "numeric underflow");
|
||||
// We should never get here:
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_underflow_error(
|
||||
inline constexpr T raise_underflow_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const ::boost::math::policies::underflow_error< ::boost::math::policies::ignore_error>&) BOOST_MATH_NOEXCEPT(T)
|
||||
@@ -402,13 +449,17 @@ inline T raise_denorm_error(
|
||||
const T& /* val */,
|
||||
const ::boost::math::policies::denorm_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::underflow_error, T>(function, message ? message : "denormalised result");
|
||||
// we never get here:
|
||||
return T(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_denorm_error(
|
||||
inline constexpr T raise_denorm_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
@@ -449,13 +500,17 @@ inline T raise_evaluation_error(
|
||||
const T& val,
|
||||
const ::boost::math::policies::evaluation_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<boost::math::evaluation_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return T(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_evaluation_error(
|
||||
inline constexpr T raise_evaluation_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
@@ -497,13 +552,17 @@ inline TargetType raise_rounding_error(
|
||||
const TargetType&,
|
||||
const ::boost::math::policies::rounding_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<boost::math::rounding_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return TargetType(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T, class TargetType>
|
||||
inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error(
|
||||
inline constexpr TargetType raise_rounding_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& val,
|
||||
@@ -512,7 +571,7 @@ inline BOOST_MATH_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:
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<TargetType>::is_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)());
|
||||
}
|
||||
|
||||
@@ -527,24 +586,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:
|
||||
BOOST_STATIC_ASSERT(std::numeric_limits<TargetType>::is_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,
|
||||
@@ -564,13 +608,17 @@ inline T raise_indeterminate_result_error(
|
||||
const R& ,
|
||||
const ::boost::math::policies::indeterminate_result_error< ::boost::math::policies::throw_on_error>&)
|
||||
{
|
||||
#ifdef BOOST_NO_EXCEPTIONS
|
||||
static_assert(sizeof(T) == 0, "Error handler called with throw_on_error and BOOST_NO_EXCEPTIONS set.");
|
||||
#else
|
||||
raise_error<std::domain_error, T>(function, message, val);
|
||||
// we never get here:
|
||||
return std::numeric_limits<T>::quiet_NaN();
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T, class R>
|
||||
inline BOOST_MATH_CONSTEXPR T raise_indeterminate_result_error(
|
||||
inline constexpr T raise_indeterminate_result_error(
|
||||
const char* ,
|
||||
const char* ,
|
||||
const T& ,
|
||||
@@ -610,7 +658,7 @@ inline T raise_indeterminate_result_error(
|
||||
} // namespace detail
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_domain_error(const char* function, const char* message, const T& val, const Policy&) noexcept(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
|
||||
{
|
||||
typedef typename Policy::domain_error_type policy_type;
|
||||
return detail::raise_domain_error(
|
||||
@@ -619,7 +667,7 @@ inline BOOST_MATH_CONSTEXPR T raise_domain_error(const char* function, const cha
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_pole_error(const char* function, const char* message, const T& val, const Policy&) noexcept(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
|
||||
{
|
||||
typedef typename Policy::pole_error_type policy_type;
|
||||
return detail::raise_pole_error(
|
||||
@@ -628,7 +676,7 @@ inline BOOST_MATH_CONSTEXPR T raise_pole_error(const char* function, const char*
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_overflow_error(const char* function, const char* message, const Policy&) noexcept(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>(
|
||||
@@ -637,7 +685,7 @@ inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const c
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_overflow_error(const char* function, const char* message, const T& val, const Policy&) noexcept(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
|
||||
{
|
||||
typedef typename Policy::overflow_error_type policy_type;
|
||||
return detail::raise_overflow_error(
|
||||
@@ -646,7 +694,7 @@ inline BOOST_MATH_CONSTEXPR T raise_overflow_error(const char* function, const c
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_underflow_error(const char* function, const char* message, const Policy&) noexcept(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>(
|
||||
@@ -655,7 +703,7 @@ inline BOOST_MATH_CONSTEXPR T raise_underflow_error(const char* function, const
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_denorm_error(const char* function, const char* message, const T& val, const Policy&) noexcept(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>(
|
||||
@@ -665,7 +713,7 @@ inline BOOST_MATH_CONSTEXPR T raise_denorm_error(const char* function, const cha
|
||||
}
|
||||
|
||||
template <class T, class 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))
|
||||
inline constexpr T raise_evaluation_error(const char* function, const char* message, const T& val, const Policy&) noexcept(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
|
||||
{
|
||||
typedef typename Policy::evaluation_error_type policy_type;
|
||||
return detail::raise_evaluation_error(
|
||||
@@ -674,7 +722,7 @@ inline BOOST_MATH_CONSTEXPR T raise_evaluation_error(const char* function, const
|
||||
}
|
||||
|
||||
template <class T, class TargetType, class 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))
|
||||
inline constexpr TargetType raise_rounding_error(const char* function, const char* message, const T& val, const TargetType& t, const Policy&) noexcept(is_noexcept_error_policy<Policy>::value && BOOST_MATH_IS_FLOAT(T))
|
||||
{
|
||||
typedef typename Policy::rounding_error_type policy_type;
|
||||
return detail::raise_rounding_error(
|
||||
@@ -683,7 +731,7 @@ inline BOOST_MATH_CONSTEXPR TargetType raise_rounding_error(const char* function
|
||||
}
|
||||
|
||||
template <class T, class R, class 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))
|
||||
inline constexpr T raise_indeterminate_result_error(const char* function, const char* message, const T& val, const R& result, const Policy&) noexcept(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(
|
||||
@@ -698,19 +746,19 @@ namespace detail
|
||||
{
|
||||
|
||||
template <class R, class T, class Policy>
|
||||
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_FORCEINLINE bool check_overflow(T val, R* result, const char* function, const Policy& pol) noexcept(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>())
|
||||
{
|
||||
boost::math::policies::detail::raise_overflow_error<R>(function, 0, pol);
|
||||
boost::math::policies::detail::raise_overflow_error<R>(function, nullptr, pol);
|
||||
*result = static_cast<R>(val);
|
||||
return true;
|
||||
}
|
||||
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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
|
||||
BOOST_FORCEINLINE bool check_overflow(std::complex<T> val, R* result, const char* function, const Policy& pol) noexcept(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;
|
||||
@@ -720,17 +768,17 @@ 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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
|
||||
BOOST_FORCEINLINE bool check_underflow(T val, R* result, const char* function, const Policy& pol) noexcept(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))
|
||||
{
|
||||
*result = static_cast<R>(boost::math::policies::detail::raise_underflow_error<R>(function, 0, pol));
|
||||
*result = static_cast<R>(boost::math::policies::detail::raise_underflow_error<R>(function, nullptr, pol));
|
||||
return true;
|
||||
}
|
||||
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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
|
||||
BOOST_FORCEINLINE bool check_underflow(std::complex<T> val, R* result, const char* function, const Policy& pol) noexcept(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;
|
||||
@@ -740,7 +788,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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
|
||||
BOOST_FORCEINLINE bool check_denorm(T val, R* result, const char* function, const Policy& pol) noexcept(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))
|
||||
@@ -751,7 +799,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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && (Policy::value != throw_on_error) && (Policy::value != user_error))
|
||||
BOOST_FORCEINLINE bool check_denorm(std::complex<T> val, R* result, const char* function, const Policy& pol) noexcept(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;
|
||||
@@ -763,28 +811,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 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))
|
||||
BOOST_FORCEINLINE constexpr bool check_overflow(T /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
|
||||
{ return false; }
|
||||
template <class R, class T>
|
||||
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))
|
||||
BOOST_FORCEINLINE constexpr bool check_overflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const overflow_error<ignore_error>&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
|
||||
{ return false; }
|
||||
template <class R, class T>
|
||||
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))
|
||||
BOOST_FORCEINLINE constexpr bool check_underflow(T /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
|
||||
{ return false; }
|
||||
template <class R, class T>
|
||||
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))
|
||||
BOOST_FORCEINLINE constexpr bool check_underflow(std::complex<T> /* val */, R* /* result */, const char* /* function */, const underflow_error<ignore_error>&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
|
||||
{ return false; }
|
||||
template <class R, class T>
|
||||
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))
|
||||
BOOST_FORCEINLINE constexpr bool check_denorm(T /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&) noexcept(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T))
|
||||
{ return false; }
|
||||
template <class R, class T>
|
||||
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))
|
||||
BOOST_FORCEINLINE constexpr bool check_denorm(std::complex<T> /* val */, R* /* result*/, const char* /* function */, const denorm_error<ignore_error>&) noexcept(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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(R) && BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
|
||||
BOOST_FORCEINLINE R checked_narrowing_cast(T val, const char* function) noexcept(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;
|
||||
@@ -804,7 +852,7 @@ inline R checked_narrowing_cast(T val, const char* function) BOOST_NOEXCEPT_IF(B
|
||||
}
|
||||
|
||||
template <class T, class Policy>
|
||||
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)
|
||||
inline void check_series_iterations(const char* function, std::uintmax_t max_iter, const Policy& pol) noexcept(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
|
||||
{
|
||||
if(max_iter >= policies::get_max_series_iterations<Policy>())
|
||||
raise_evaluation_error<T>(
|
||||
@@ -813,7 +861,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) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
|
||||
inline void check_root_iterations(const char* function, std::uintmax_t max_iter, const Policy& pol) noexcept(BOOST_MATH_IS_FLOAT(T) && is_noexcept_error_policy<Policy>::value)
|
||||
{
|
||||
if(max_iter >= policies::get_max_root_iterations<Policy>())
|
||||
raise_evaluation_error<T>(
|
||||
@@ -837,7 +885,7 @@ std::pair<T, T> pair_from_single(const T& val) BOOST_MATH_NOEXCEPT(T)
|
||||
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user