diff --git a/config/has_128bit_floatmax_t.cpp b/config/has_128bit_floatmax_t.cpp index 17205c450..e11b84c25 100644 --- a/config/has_128bit_floatmax_t.cpp +++ b/config/has_128bit_floatmax_t.cpp @@ -4,13 +4,12 @@ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include -#include #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() { diff --git a/doc/sf/factorials.qbk b/doc/sf/factorials.qbk index 285c65730..f58614171 100644 --- a/doc/sf/factorials.qbk +++ b/doc/sf/factorials.qbk @@ -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::value); + static_assert(!std::is_integral::value, "Type T must not be an integral type"); // factorial(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::value); + static_assert(!std::is_integral::value, "Type T must not be an integral type"); // factorial(n) is not implemented // because it would overflow integral type T for too small n // to be useful. Use instead a floating-point type, diff --git a/include/boost/math/distributions/cauchy.hpp b/include/boost/math/distributions/cauchy.hpp index 0713ea763..a026441d8 100644 --- a/include/boost/math/distributions/cauchy.hpp +++ b/include/boost/math/distributions/cauchy.hpp @@ -271,7 +271,7 @@ template inline RealType mean(const cauchy_distribution&) { // 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( "boost::math::mean(cauchy<%1%>&)", @@ -285,7 +285,7 @@ inline RealType variance(const cauchy_distribution& /*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( "boost::math::variance(cauchy<%1%>&)", @@ -310,7 +310,7 @@ inline RealType skewness(const cauchy_distribution& /*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( "boost::math::skewness(cauchy<%1%>&)", @@ -324,7 +324,7 @@ inline RealType kurtosis(const cauchy_distribution& /*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( "boost::math::kurtosis(cauchy<%1%>&)", @@ -338,7 +338,7 @@ inline RealType kurtosis_excess(const cauchy_distribution& /*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( "boost::math::kurtosis_excess(cauchy<%1%>&)", diff --git a/include/boost/math/distributions/find_location.hpp b/include/boost/math/distributions/find_location.hpp index bff79e55c..f7ed66c55 100644 --- a/include/boost/math/distributions/find_location.hpp +++ b/include/boost/math/distributions/find_location.hpp @@ -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::value); - BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); + static_assert(::boost::math::tools::is_distribution::value, "The provided distribution does not meet the conceptual requirements of a distribution."); + static_assert(::boost::math::tools::is_scaled_distribution::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution."); #endif static const char* function = "boost::math::find_location&, %1%)"; diff --git a/include/boost/math/distributions/find_scale.hpp b/include/boost/math/distributions/find_scale.hpp index b74a1e29b..00a02ecab 100644 --- a/include/boost/math/distributions/find_scale.hpp +++ b/include/boost/math/distributions/find_scale.hpp @@ -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::value); - BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); + static_assert(::boost::math::tools::is_distribution::value, "The provided distribution does not meet the conceptual requirements of a distribution."); + static_assert(::boost::math::tools::is_scaled_distribution::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution."); #endif static const char* function = "boost::math::find_scale(%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::value); - BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); + static_assert(::boost::math::tools::is_distribution::value, "The provided distribution does not meet the conceptual requirements of a distribution."); + static_assert(::boost::math::tools::is_scaled_distribution::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution."); #endif static const char* function = "boost::math::find_scale(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::value); - BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); + static_assert(::boost::math::tools::is_distribution::value, "The provided distribution does not meet the conceptual requirements of a distribution."); + static_assert(::boost::math::tools::is_scaled_distribution::value, "The provided distribution does not meet the conceptual requirements of a scaled distribution."); #endif static const char* function = "boost::math::find_scale(complement(%1%, %1%, %1%, Policy))"; diff --git a/include/boost/math/distributions/non_central_beta.hpp b/include/boost/math/distributions/non_central_beta.hpp index e2972b500..3c8eb7112 100644 --- a/include/boost/math/distributions/non_central_beta.hpp +++ b/include/boost/math/distributions/non_central_beta.hpp @@ -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( 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( function, diff --git a/include/boost/math/policies/error_handling.hpp b/include/boost/math/policies/error_handling.hpp index cbe77687a..45941e3d1 100644 --- a/include/boost/math/policies/error_handling.hpp +++ b/include/boost/math/policies/error_handling.hpp @@ -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::is_specialized); + static_assert(std::numeric_limits::is_specialized, "The target type must be specialized."); return val > 0 ? (std::numeric_limits::max)() : (std::numeric_limits::is_integer ? (std::numeric_limits::min)() : -(std::numeric_limits::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::is_specialized); + static_assert(std::numeric_limits::is_specialized, "The target type must be specialized."); return val > 0 ? (std::numeric_limits::max)() : (std::numeric_limits::is_integer ? (std::numeric_limits::min)() : -(std::numeric_limits::max)()); } diff --git a/include/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp index 947f4d666..7eaa48139 100644 --- a/include/boost/math/special_functions/beta.hpp +++ b/include/boost/math/special_functions/beta.hpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include 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::value >= 100 ? 50 : ::boost::math::max_factorial::value >= ::boost::math::max_factorial::value ? 30 : ::boost::math::max_factorial::value >= ::boost::math::max_factorial::value ? 15 : 1); - BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial::value >= ::boost::math::max_factorial::value); + static_assert(::boost::math::max_factorial::value >= ::boost::math::max_factorial::value, "Type does not provide for 35-50 digits of accuracy."); }; template <> struct Pn_size { - BOOST_STATIC_CONSTANT(unsigned, value = 15); // ~8-15 digit accuracy - BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial::value >= 30); + static constexpr unsigned value = 15; // ~8-15 digit accuracy + static_assert(::boost::math::max_factorial::value >= 30, "Type does not provide for 8-15 digits of accuracy."); }; template <> struct Pn_size { - BOOST_STATIC_CONSTANT(unsigned, value = 30); // 16-20 digit accuracy - BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial::value >= 60); + static constexpr unsigned value = 30; // 16-20 digit accuracy + static_assert(::boost::math::max_factorial::value >= 60, "Type does not provide for 16-20 digits of accuracy."); }; template <> struct Pn_size { - BOOST_STATIC_CONSTANT(unsigned, value = 50); // ~35-50 digit accuracy - BOOST_MATH_STATIC_ASSERT(::boost::math::max_factorial::value >= 100); + static constexpr unsigned value = 50; // ~35-50 digit accuracy + static_assert(::boost::math::max_factorial::value >= 100, "Type does not provide for ~35-50 digits of accuracy"); }; template diff --git a/include/boost/math/special_functions/binomial.hpp b/include/boost/math/special_functions/binomial.hpp index 9a242d57d..3e55530bf 100644 --- a/include/boost/math/special_functions/binomial.hpp +++ b/include/boost/math/special_functions/binomial.hpp @@ -14,13 +14,14 @@ #include #include #include +#include namespace boost{ namespace math{ template T binomial_coefficient(unsigned n, unsigned k, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::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) diff --git a/include/boost/math/special_functions/cbrt.hpp b/include/boost/math/special_functions/cbrt.hpp index 1896c82aa..77cd5f0ae 100644 --- a/include/boost/math/special_functions/cbrt.hpp +++ b/include/boost/math/special_functions/cbrt.hpp @@ -87,7 +87,7 @@ T cbrt_imp(T z, const Policy& pol) using shift_type = typename largest_cbrt_int_type::type; - BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits::radix == 2); + static_assert( ::std::numeric_limits::radix == 2, "The radix of the type to shift to must be 2."); if(abs(i_exp3) < std::numeric_limits::digits) { diff --git a/include/boost/math/special_functions/detail/fp_traits.hpp b/include/boost/math/special_functions/detail/fp_traits.hpp index c0f5b5914..b2d3d7ea5 100644 --- a/include/boost/math/special_functions/detail/fp_traits.hpp +++ b/include/boost/math/special_functions/detail/fp_traits.hpp @@ -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 }; diff --git a/include/boost/math/special_functions/detail/lanczos_sse2.hpp b/include/boost/math/special_functions/detail/lanczos_sse2.hpp index 75aeff4d1..43353ce2b 100644 --- a/include/boost/math/special_functions/detail/lanczos_sse2.hpp +++ b/include/boost/math/special_functions/detail/lanczos_sse2.hpp @@ -210,7 +210,7 @@ inline double lanczos13m53::lanczos_sum_expG_scaled(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(const long double& x) diff --git a/include/boost/math/special_functions/detail/unchecked_factorial.hpp b/include/boost/math/special_functions/detail/unchecked_factorial.hpp index e69b87a14..50df30e60 100644 --- a/include/boost/math/special_functions/detail/unchecked_factorial.hpp +++ b/include/boost/math/special_functions/detail/unchecked_factorial.hpp @@ -30,6 +30,8 @@ #include #endif +#include + #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::init unchecked_factorial_init template inline T unchecked_factorial_imp(unsigned i, const std::integral_constant&) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::value, "Type T must not be a floating point type"); // factorial(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 inline T unchecked_factorial_imp(unsigned i, const std::integral_constant&) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::value, "Type T must not be a floating point type"); // factorial(n) is not implemented // because it would overflow integral type T for too small n // to be useful. Use instead a floating-point type, diff --git a/include/boost/math/special_functions/factorials.hpp b/include/boost/math/special_functions/factorials.hpp index f21bd6d6c..7ed62a1f3 100644 --- a/include/boost/math/special_functions/factorials.hpp +++ b/include/boost/math/special_functions/factorials.hpp @@ -29,7 +29,7 @@ namespace boost { namespace math template inline T factorial(unsigned i, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::value, "Type T must not be an integral type"); // factorial(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(unsigned i) template T double_factorial(unsigned i, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::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 T rising_factorial_imp(T x, int n, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::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 inline T falling_factorial_imp(T x, unsigned n, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(!boost::is_integral::value); + static_assert(!std::is_integral::value, "Type T must not be an integral type"); BOOST_MATH_STD_USING // ADL of std names if(x == 0) return 0; diff --git a/include/boost/math/special_functions/next.hpp b/include/boost/math/special_functions/next.hpp index 344894985..b186ee332 100644 --- a/include/boost/math/special_functions/next.hpp +++ b/include/boost/math/special_functions/next.hpp @@ -72,8 +72,8 @@ inline const T& normalize_value(const T& val, const std::false_type&) { return v template inline T normalize_value(const T& val, const std::true_type&) { - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::radix != 2, "Type T must be specialized."); boost::intmax_t shift = (boost::intmax_t)std::numeric_limits::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 inline T calc_min_shifted(const std::false_type&) { - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::radix != 2, "Type T must be specialized.") return scalbn(tools::min_value(), std::numeric_limits::digits + 1); } @@ -233,8 +233,8 @@ T float_next_imp(const T& val, const std::false_type&, const Policy& pol) { typedef typename exponent_type::type exponent_type; - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::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::type exponent_type; - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::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 T float_distance_imp(const T& a, const T& b, const std::false_type&, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::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 T float_advance_imp(T val, int distance, const std::false_type&, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::radix != 2, "Type T must be specialized.") BOOST_MATH_STD_USING // diff --git a/include/boost/math/special_functions/ulp.hpp b/include/boost/math/special_functions/ulp.hpp index f1f364c2a..34545ccfc 100644 --- a/include/boost/math/special_functions/ulp.hpp +++ b/include/boost/math/special_functions/ulp.hpp @@ -52,8 +52,8 @@ T ulp_imp(const T& val, const std::true_type&, const Policy& pol) template T ulp_imp(const T& val, const std::false_type&, const Policy& pol) { - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::is_specialized); - BOOST_MATH_STATIC_ASSERT(std::numeric_limits::radix != 2); + static_assert(std::numeric_limits::is_specialized, "Type T must be specialized."); + static_assert(std::numeric_limits::radix != 2, "Type T must be specialized.") BOOST_MATH_STD_USING int expon; static const char* function = "ulp<%1%>(%1%)"; diff --git a/include/boost/math/tools/convert_from_string.hpp b/include/boost/math/tools/convert_from_string.hpp index 43532fa77..534911cd9 100644 --- a/include/boost/math/tools/convert_from_string.hpp +++ b/include/boost/math/tools/convert_from_string.hpp @@ -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(p); #endif diff --git a/include/boost/math/tools/precision.hpp b/include/boost/math/tools/precision.hpp index 3d74d56c0..def530388 100644 --- a/include/boost/math/tools/precision.hpp +++ b/include/boost/math/tools/precision.hpp @@ -40,13 +40,9 @@ namespace tools template 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::is_specialized); - BOOST_MATH_STATIC_ASSERT( ::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10); -#else - BOOST_MATH_ASSERT(::std::numeric_limits::is_specialized); - BOOST_MATH_ASSERT(::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10); -#endif + static_assert( ::std::numeric_limits::is_specialized, "Type T must be specialized"); + static_assert( ::std::numeric_limits::radix == 2 || ::std::numeric_limits::radix == 10, "Type T must have a radix of 2 or 10"); + return std::numeric_limits::radix == 2 ? std::numeric_limits::digits : ((std::numeric_limits::digits + 1) * 1000L) / 301L; @@ -55,11 +51,7 @@ inline BOOST_MATH_CONSTEXPR int digits(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(T) template 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::is_specialized); -#else - BOOST_MATH_ASSERT(::std::numeric_limits::is_specialized); -#endif + static_assert( ::std::numeric_limits::is_specialized, "Type T must be specialized"); return (std::numeric_limits::max)(); } // Also used as a finite 'infinite' value for - and +infinity, for example: // -max_value = -1.79769e+308, max_value = 1.79769e+308. @@ -67,11 +59,8 @@ inline BOOST_MATH_CONSTEXPR T max_value(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(T)) B template 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::is_specialized); -#else - BOOST_MATH_ASSERT(::std::numeric_limits::is_specialized); -#endif + static_assert( ::std::numeric_limits::is_specialized, "Type T must be specialized"); + return (std::numeric_limits::min)(); } @@ -196,7 +185,7 @@ struct log_limit_traits std::integral_constant >::type tag_type; BOOST_STATIC_CONSTANT(bool, value = tag_type::value ? true : false); - BOOST_MATH_STATIC_ASSERT(::std::numeric_limits::is_specialized || (value == 0)); + static_assert(::std::numeric_limits::is_specialized || (value == 0), "Type T must be specialized or equal to 0"); }; template struct log_limit_noexcept_traits_imp : public log_limit_traits {}; diff --git a/test/compile_test/test_traits.cpp b/test/compile_test/test_traits.cpp index 63818f40a..d1245aa2e 100644 --- a/test/compile_test/test_traits.cpp +++ b/test/compile_test/test_traits.cpp @@ -5,52 +5,50 @@ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include -#include #include using namespace boost::math; -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution >::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution >::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_distribution::value); - -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution >::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution >::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); -BOOST_MATH_STATIC_ASSERT(::boost::math::tools::is_scaled_distribution::value == false); +static_assert(::boost::math::tools::is_distribution::value == false, "double is erroneously identified as a distribution"); +static_assert(::boost::math::tools::is_distribution::value == false, "int is erroneously identified as a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "bernoulli distribution should be identified as a distribution"); +static_assert(::boost::math::tools::is_distribution >::value, "beta distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "binomial distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "cauchy distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "chi squared distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "exponential distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "extreme value distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "fisher f distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution >::value, "gamma distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "lognormal distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "negative distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "normal distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "pareto distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "poisson distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "rayleigh distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "students t distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "triangular distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "uniform distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_distribution::value, "weibull distribution should be identified a distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "double is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "int double is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "bernoulli distribution is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution >::value == false, "beta distribution is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "binomial distribution should be identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value, "cauchy distribution should be identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "chi squared is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "exponential distribution is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value, "extreme value distribution should be identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "fisher f is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution >::value == false, "gamma distribution is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value, "lognormal distribution should be identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "negative binomial is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value, "normal distribution should be identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "pareto is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "poisson is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "rayleigh is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "students t is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "triangular is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "uniform distribution is erroneously identified as a scaled distribution"); +static_assert(::boost::math::tools::is_scaled_distribution::value == false, "weibull distribution is erroneously identified as a scaled distribution");