2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

Replace BOOST_STATIC_ASSERT with static_assert

and add useful error messages
This commit is contained in:
Matt Borland
2021-03-14 22:06:15 +03:00
parent fbadd8d653
commit 0339733a79
19 changed files with 109 additions and 120 deletions

View File

@@ -4,13 +4,12 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/cstdfloat.hpp>
#include <boost/math/tools/assert.hpp>
#ifndef BOOST_FLOAT128_C
#error "There is no 128 bit floating point type"
#endif
BOOST_MATH_STATIC_ASSERT(sizeof(boost::floatmax_t) * CHAR_BIT == 128);
static_assert(sizeof(boost::floatmax_t) * CHAR_BIT == 128, "floatmax_t is not a 128-bit floating point type");
int main()
{

View File

@@ -45,7 +45,7 @@ and not an integer type - that would overflow far too easily for quite small val
The source code `static_assert` and comment just after the will be:
``
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
// factorial<unsigned int>(n) is not implemented
// because it would overflow integral type T for too small n
// to be useful. Use instead a floating-point type,
@@ -155,7 +155,7 @@ and not an integer type - that would overflow far too easily!
The source code `static_assert` and comment just after the will be:
``
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
// factorial<unsigned int>(n) is not implemented
// because it would overflow integral type T for too small n
// to be useful. Use instead a floating-point type,

View File

@@ -271,7 +271,7 @@ template <class RealType, class Policy>
inline RealType mean(const cauchy_distribution<RealType, Policy>&)
{ // There is no mean:
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::mean(cauchy<%1%>&)",
@@ -285,7 +285,7 @@ inline RealType variance(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no variance:
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::variance(cauchy<%1%>&)",
@@ -310,7 +310,7 @@ inline RealType skewness(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no skewness:
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::skewness(cauchy<%1%>&)",
@@ -324,7 +324,7 @@ inline RealType kurtosis(const cauchy_distribution<RealType, Policy>& /*dist*/)
{
// There is no kurtosis:
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::kurtosis(cauchy<%1%>&)",
@@ -338,7 +338,7 @@ inline RealType kurtosis_excess(const cauchy_distribution<RealType, Policy>& /*d
{
// There is no kurtosis excess:
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "assert type is undefined");
return policies::raise_domain_error<RealType>(
"boost::math::kurtosis_excess(cauchy<%1%>&)",

View File

@@ -42,8 +42,8 @@ namespace boost
// Will fail to compile here if try to use with a distribution without scale & location,
// for example pareto, and many others. These tests are disabled by the pp-logic
// above if the compiler doesn't support the SFINAE tricks used in the traits class.
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<Dist>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<Dist>::value);
static_assert(::boost::math::tools::is_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a distribution.");
static_assert(::boost::math::tools::is_scaled_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution.");
#endif
static const char* function = "boost::math::find_location<Dist, Policy>&, %1%)";

View File

@@ -40,8 +40,8 @@ namespace boost
)
{
#if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<Dist>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<Dist>::value);
static_assert(::boost::math::tools::is_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a distribution.");
static_assert(::boost::math::tools::is_scaled_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution.");
#endif
static const char* function = "boost::math::find_scale<Dist, Policy>(%1%, %1%, %1%, Policy)";
@@ -112,8 +112,8 @@ namespace boost
// << endl;
#if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<Dist>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<Dist>::value);
static_assert(::boost::math::tools::is_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a distribution.");
static_assert(::boost::math::tools::is_scaled_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution.");
#endif
static const char* function = "boost::math::find_scale<Dist, Policy>(complement(%1%, %1%, %1%, Policy))";
@@ -166,8 +166,8 @@ namespace boost
// << endl;
#if !defined(BOOST_NO_SFINAE) && !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<Dist>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<Dist>::value);
static_assert(::boost::math::tools::is_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a distribution.");
static_assert(::boost::math::tools::is_scaled_distribution<Dist>::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution.");
#endif
static const char* function = "boost::math::find_scale<Dist, Policy>(complement(%1%, %1%, %1%, Policy))";

View File

@@ -800,7 +800,7 @@ namespace boost
{ // skewness = sqrt(l).
const char* function = "boost::math::non_central_beta_distribution<%1%>::skewness()";
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "Assert type is undefined.");
return policies::raise_evaluation_error<RealType>(
function,
@@ -813,7 +813,7 @@ namespace boost
{
const char* function = "boost::math::non_central_beta_distribution<%1%>::kurtosis_excess()";
typedef typename Policy::assert_undefined_type assert_type;
BOOST_MATH_STATIC_ASSERT(assert_type::value == 0);
static_assert(assert_type::value == 0, "Assert type is undefined.");
return policies::raise_evaluation_error<RealType>(
function,

View File

@@ -512,7 +512,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_MATH_STATIC_ASSERT(std::numeric_limits<TargetType>::is_specialized);
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be 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,7 +527,7 @@ 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_MATH_STATIC_ASSERT(std::numeric_limits<TargetType>::is_specialized);
static_assert(std::numeric_limits<TargetType>::is_specialized, "The target type must be 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)());
}

View File

@@ -21,7 +21,7 @@
#include <boost/math/special_functions/trunc.hpp>
#include <boost/math/tools/roots.hpp>
#include <boost/math/tools/assert.hpp>
#include <boost/config/no_tr1/cmath.hpp>
#include <cmath>
namespace boost{ namespace math{
@@ -791,29 +791,29 @@ struct Pn_size
{
// This is likely to be enough for ~35-50 digit accuracy
// but it's hard to quantify exactly:
BOOST_STATIC_CONSTANT(unsigned, value =
static constexpr unsigned value =
::boost::math::max_factorial<T>::value >= 100 ? 50
: ::boost::math::max_factorial<T>::value >= ::boost::math::max_factorial<double>::value ? 30
: ::boost::math::max_factorial<T>::value >= ::boost::math::max_factorial<float>::value ? 15 : 1);
BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial<T>::value >= ::boost::math::max_factorial<float>::value);
static_assert(::boost::math::max_factorial<T>::value >= ::boost::math::max_factorial<float>::value, "Type does not provide for 35-50 digits of accuracy.");
};
template <>
struct Pn_size<float>
{
BOOST_STATIC_CONSTANT(unsigned, value = 15); // ~8-15 digit accuracy
BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial<float>::value >= 30);
static constexpr unsigned value = 15; // ~8-15 digit accuracy
static_assert(::boost::math::max_factorial<float>::value >= 30, "Type does not provide for 8-15 digits of accuracy.");
};
template <>
struct Pn_size<double>
{
BOOST_STATIC_CONSTANT(unsigned, value = 30); // 16-20 digit accuracy
BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial<double>::value >= 60);
static constexpr unsigned value = 30; // 16-20 digit accuracy
static_assert(::boost::math::max_factorial<double>::value >= 60, "Type does not provide for 16-20 digits of accuracy.");
};
template <>
struct Pn_size<long double>
{
BOOST_STATIC_CONSTANT(unsigned, value = 50); // ~35-50 digit accuracy
BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial<long double>::value >= 100);
static constexpr unsigned value = 50; // ~35-50 digit accuracy
static_assert(::boost::math::max_factorial<long double>::value >= 100, "Type does not provide for ~35-50 digits of accuracy");
};
template <class T, class Policy>

View File

@@ -14,13 +14,14 @@
#include <boost/math/special_functions/factorials.hpp>
#include <boost/math/special_functions/beta.hpp>
#include <boost/math/policies/error_handling.hpp>
#include <type_traits>
namespace boost{ namespace math{
template <class T, class Policy>
T binomial_coefficient(unsigned n, unsigned k, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
BOOST_MATH_STD_USING
static const char* function = "boost::math::binomial_coefficient<%1%>(unsigned, unsigned)";
if(k > n)

View File

@@ -87,7 +87,7 @@ T cbrt_imp(T z, const Policy& pol)
using shift_type = typename largest_cbrt_int_type<T>::type;
BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits<shift_type>::radix == 2);
static_assert( ::std::numeric_limits<shift_type>::radix == 2, "The radix of the type to shift to must be 2.");
if(abs(i_exp3) < std::numeric_limits<shift_type>::digits)
{

View File

@@ -222,7 +222,7 @@ private:
#elif BOOST_ENDIAN_LITTLE_BYTE
BOOST_STATIC_CONSTANT(int, offset_ = 4);
#else
BOOST_MATH_STATIC_ASSERT(false);
static_assert(false, "Endian type could not be identified");
#endif
};
@@ -282,7 +282,7 @@ private:
#elif BOOST_ENDIAN_LITTLE_BYTE
BOOST_STATIC_CONSTANT(int, offset_ = 4);
#else
BOOST_MATH_STATIC_ASSERT(false);
static_assert(false, "Endian type could not be identified");
#endif
};
@@ -396,7 +396,7 @@ private:
#elif BOOST_ENDIAN_LITTLE_BYTE
BOOST_STATIC_CONSTANT(int, offset_ = 12);
#else
BOOST_MATH_STATIC_ASSERT(false);
static_assert(false, "Endian type could not be identified");
#endif
};
@@ -477,7 +477,7 @@ private:
#elif BOOST_ENDIAN_LITTLE_BYTE
BOOST_STATIC_CONSTANT(int, offset_ = 12);
#else
BOOST_MATH_STATIC_ASSERT(false);
static_assert(false, "Endian type could not be identified");
#endif
};

View File

@@ -210,7 +210,7 @@ inline double lanczos13m53::lanczos_sum_expG_scaled<double>(const double& x)
#ifdef _MSC_VER
BOOST_MATH_STATIC_ASSERT(sizeof(double) == sizeof(long double));
static_assert(sizeof(double) == sizeof(long double), "sizeof(long double) != sizeof(double) is not supported");
template <>
inline long double lanczos13m53::lanczos_sum<long double>(const long double& x)

View File

@@ -30,6 +30,8 @@
#include <boost/array.hpp>
#endif
#include <type_traits>
#if defined(__GNUC__) && defined(BOOST_MATH_USE_FLOAT128)
//
// This is the only way we can avoid
@@ -702,7 +704,7 @@ const typename unchecked_factorial_initializer<T>::init unchecked_factorial_init
template <class T, int N>
inline T unchecked_factorial_imp(unsigned i, const std::integral_constant<int, N>&)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be a floating point type");
// factorial<unsigned int>(n) is not implemented
// because it would overflow integral type T for too small n
// to be useful. Use instead a floating-point type,
@@ -822,7 +824,7 @@ inline T unchecked_factorial_imp(unsigned i, const std::integral_constant<int, N
template <class T>
inline T unchecked_factorial_imp(unsigned i, const std::integral_constant<int, 0>&)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be a floating point type");
// factorial<unsigned int>(n) is not implemented
// because it would overflow integral type T for too small n
// to be useful. Use instead a floating-point type,

View File

@@ -29,7 +29,7 @@ namespace boost { namespace math
template <class T, class Policy>
inline T factorial(unsigned i, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
// factorial<unsigned int>(n) is not implemented
// because it would overflow integral type T for too small n
// to be useful. Use instead a floating-point type,
@@ -73,7 +73,7 @@ inline double factorial<double>(unsigned i)
template <class T, class Policy>
T double_factorial(unsigned i, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
BOOST_MATH_STD_USING // ADL lookup of std names
if(i & 1)
{
@@ -116,7 +116,7 @@ namespace detail{
template <class T, class Policy>
T rising_factorial_imp(T x, int n, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
if(x < 0)
{
//
@@ -164,7 +164,7 @@ T rising_factorial_imp(T x, int n, const Policy& pol)
template <class T, class Policy>
inline T falling_factorial_imp(T x, unsigned n, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(!boost::is_integral<T>::value);
static_assert(!std::is_integral<T>::value, "Type T must not be an integral type");
BOOST_MATH_STD_USING // ADL of std names
if(x == 0)
return 0;

View File

@@ -72,8 +72,8 @@ inline const T& normalize_value(const T& val, const std::false_type&) { return v
template <class T>
inline T normalize_value(const T& val, const std::true_type&)
{
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.");
boost::intmax_t shift = (boost::intmax_t)std::numeric_limits<T>::digits - (boost::intmax_t)ilogb(val) - 1;
T result = scalbn(val, shift);
@@ -154,8 +154,8 @@ inline T calc_min_shifted(const std::true_type&)
template <class T>
inline T calc_min_shifted(const std::false_type&)
{
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
return scalbn(tools::min_value<T>(), std::numeric_limits<T>::digits + 1);
}
@@ -233,8 +233,8 @@ T float_next_imp(const T& val, const std::false_type&, const Policy& pol)
{
typedef typename exponent_type<T>::type exponent_type;
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
BOOST_MATH_STD_USING
exponent_type expon;
@@ -368,8 +368,8 @@ T float_prior_imp(const T& val, const std::false_type&, const Policy& pol)
{
typedef typename exponent_type<T>::type exponent_type;
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
BOOST_MATH_STD_USING
exponent_type expon;
@@ -573,8 +573,8 @@ T float_distance_imp(const T& a, const T& b, const std::true_type&, const Policy
template <class T, class Policy>
T float_distance_imp(const T& a, const T& b, const std::false_type&, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
BOOST_MATH_STD_USING
//
@@ -805,8 +805,8 @@ T float_advance_imp(T val, int distance, const std::true_type&, const Policy& po
template <class T, class Policy>
T float_advance_imp(T val, int distance, const std::false_type&, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
BOOST_MATH_STD_USING
//

View File

@@ -52,8 +52,8 @@ T ulp_imp(const T& val, const std::true_type&, const Policy& pol)
template <class T, class Policy>
T ulp_imp(const T& val, const std::false_type&, const Policy& pol)
{
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT(std::numeric_limits<T>::radix != 2);
static_assert(std::numeric_limits<T>::is_specialized, "Type T must be specialized.");
static_assert(std::numeric_limits<T>::radix != 2, "Type T must be specialized.")
BOOST_MATH_STD_USING
int expon;
static const char* function = "ulp<%1%>(%1%)";

View File

@@ -27,7 +27,7 @@ namespace boost{ namespace math{ namespace tools{
{
#ifdef BOOST_MATH_NO_LEXICAL_CAST
// This function should not compile, we don't have the necessary functionality to support it:
BOOST_MATH_STATIC_ASSERT(sizeof(Real) == 0);
static_assert(sizeof(Real) == 0, "sizeof(Real) should not be 0");
#else
return boost::lexical_cast<Real>(p);
#endif

View File

@@ -40,13 +40,9 @@ namespace tools
template <class T>
inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)) BOOST_NOEXCEPT
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10);
#else
BOOST_MATH_ASSERT(::std::numeric_limits<T>::is_specialized);
BOOST_MATH_ASSERT(::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10);
#endif
static_assert( ::std::numeric_limits<T>::is_specialized, "Type T must be specialized");
static_assert( ::std::numeric_limits<T>::radix == 2 || ::std::numeric_limits<T>::radix == 10, "Type T must have a radix of 2 or 10");
return std::numeric_limits<T>::radix == 2
? std::numeric_limits<T>::digits
: ((std::numeric_limits<T>::digits + 1) * 1000L) / 301L;
@@ -55,11 +51,7 @@ inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T)
template <class T>
inline BOOST_MATH_CONSTEXPR T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
#else
BOOST_MATH_ASSERT(::std::numeric_limits<T>::is_specialized);
#endif
static_assert( ::std::numeric_limits<T>::is_specialized, "Type T must be specialized");
return (std::numeric_limits<T>::max)();
} // Also used as a finite 'infinite' value for - and +infinity, for example:
// -max_value<double> = -1.79769e+308, max_value<double> = 1.79769e+308.
@@ -67,11 +59,8 @@ inline BOOST_MATH_CONSTEXPR T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) B
template <class T>
inline BOOST_MATH_CONSTEXPR T min_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) BOOST_MATH_NOEXCEPT(T)
{
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits<T>::is_specialized);
#else
BOOST_MATH_ASSERT(::std::numeric_limits<T>::is_specialized);
#endif
static_assert( ::std::numeric_limits<T>::is_specialized, "Type T must be specialized");
return (std::numeric_limits<T>::min)();
}
@@ -196,7 +185,7 @@ struct log_limit_traits
std::integral_constant<int, 0>
>::type tag_type;
BOOST_STATIC_CONSTANT(bool, value = tag_type::value ? true : false);
BOOST_MATH_STATIC_ASSERT(::std::numeric_limits<T>::is_specialized || (value == 0));
static_assert(::std::numeric_limits<T>::is_specialized || (value == 0), "Type T must be specialized or equal to 0");
};
template <class T, bool b> struct log_limit_noexcept_traits_imp : public log_limit_traits<T> {};

View File

@@ -5,52 +5,50 @@
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/math/tools/traits.hpp>
#include <boost/math/tools/assert.hpp>
#include <boost/math/distributions.hpp>
using namespace boost::math;
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<double>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<int>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<bernoulli>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<beta_distribution<> >::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<binomial>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<cauchy>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<chi_squared>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<exponential>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<extreme_value>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<fisher_f>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<gamma_distribution<> >::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<lognormal>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<negative_binomial>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<normal>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<pareto>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<poisson>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<rayleigh>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<students_t>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<triangular>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<uniform>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution<weibull>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<double>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<int>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<bernoulli>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<beta_distribution<> >::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<binomial>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<cauchy>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<chi_squared>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<exponential>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<extreme_value>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<fisher_f>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<gamma_distribution<> >::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<lognormal>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<negative_binomial>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<normal>::value);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<pareto>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<poisson>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<rayleigh>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<students_t>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<triangular>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<uniform>::value == false);
BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution<weibull>::value == false);
static_assert(::boost::math::tools::is_distribution<double>::value == false, "double is erroneously identified as a distribution");
static_assert(::boost::math::tools::is_distribution<int>::value == false, "int is erroneously identified as a distribution");
static_assert(::boost::math::tools::is_distribution<bernoulli>::value, "bernoulli distribution should be identified as a distribution");
static_assert(::boost::math::tools::is_distribution<beta_distribution<> >::value, "beta distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<binomial>::value, "binomial distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<cauchy>::value, "cauchy distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<chi_squared>::value, "chi squared distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<exponential>::value, "exponential distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<extreme_value>::value, "extreme value distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<fisher_f>::value, "fisher f distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<gamma_distribution<> >::value, "gamma distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<lognormal>::value, "lognormal distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<negative_binomial>::value, "negative distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<normal>::value, "normal distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<pareto>::value, "pareto distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<poisson>::value, "poisson distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<rayleigh>::value, "rayleigh distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<students_t>::value, "students t distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<triangular>::value, "triangular distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<uniform>::value, "uniform distribution should be identified a distribution");
static_assert(::boost::math::tools::is_distribution<weibull>::value, "weibull distribution should be identified a distribution");
static_assert(::boost::math::tools::is_scaled_distribution<double>::value == false, "double is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<int>::value == false, "int double is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<bernoulli>::value == false, "bernoulli distribution is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<beta_distribution<> >::value == false, "beta distribution is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<binomial>::value == false, "binomial distribution should be identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<cauchy>::value, "cauchy distribution should be identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<chi_squared>::value == false, "chi squared is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<exponential>::value == false, "exponential distribution is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<extreme_value>::value, "extreme value distribution should be identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<fisher_f>::value == false, "fisher f is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<gamma_distribution<> >::value == false, "gamma distribution is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<lognormal>::value, "lognormal distribution should be identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<negative_binomial>::value == false, "negative binomial is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<normal>::value, "normal distribution should be identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<pareto>::value == false, "pareto is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<poisson>::value == false, "poisson is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<rayleigh>::value == false, "rayleigh is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<students_t>::value == false, "students t is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<triangular>::value == false, "triangular is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<uniform>::value == false, "uniform distribution is erroneously identified as a scaled distribution");
static_assert(::boost::math::tools::is_scaled_distribution<weibull>::value == false, "weibull distribution is erroneously identified as a scaled distribution");