2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-27 19:12:08 +00:00

Added a couple of static assertions to prevent misuse.

[SVN r53338]
This commit is contained in:
John Maddock
2009-05-28 08:52:05 +00:00
parent 3ec19713e6
commit 6feccbee3d
2 changed files with 5 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ namespace boost{ namespace math{
template <class T, class Policy>
T binomial_coefficient(unsigned n, unsigned k, const Policy& pol)
{
BOOST_STATIC_ASSERT(!boost::is_integral<T>::value);
BOOST_MATH_STD_USING
static const char* function = "boost::math::binomial_coefficient<%1%>(unsigned, unsigned)";
if(k > n)

View File

@@ -30,6 +30,7 @@ namespace boost { namespace math
template <class T, class Policy>
inline T factorial(unsigned i, const Policy& pol)
{
BOOST_STATIC_ASSERT(!boost::is_integral<T>::value);
BOOST_MATH_STD_USING // Aid ADL for floor.
if(i <= max_factorial<T>::value)
@@ -66,6 +67,7 @@ inline double factorial<double>(unsigned i)
template <class T, class Policy>
T double_factorial(unsigned i, const Policy& pol)
{
BOOST_STATIC_ASSERT(!boost::is_integral<T>::value);
BOOST_MATH_STD_USING // ADL lookup of std names
if(i & 1)
{
@@ -108,6 +110,7 @@ namespace detail{
template <class T, class Policy>
T rising_factorial_imp(T x, int n, const Policy& pol)
{
BOOST_STATIC_ASSERT(!boost::is_integral<T>::value);
if(x < 0)
{
//
@@ -143,6 +146,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_STATIC_ASSERT(!boost::is_integral<T>::value);
BOOST_MATH_STD_USING // ADL of std names
if(x == 0)
return 0;