Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53338 - trunk/boost/math/special_functions
From: john_at_[hidden]
Date: 2009-05-28 04:52:07


Author: johnmaddock
Date: 2009-05-28 04:52:05 EDT (Thu, 28 May 2009)
New Revision: 53338
URL: http://svn.boost.org/trac/boost/changeset/53338

Log:
Added a couple of static assertions to prevent misuse.
Text files modified:
   trunk/boost/math/special_functions/binomial.hpp | 1 +
   trunk/boost/math/special_functions/factorials.hpp | 4 ++++
   2 files changed, 5 insertions(+), 0 deletions(-)

Modified: trunk/boost/math/special_functions/binomial.hpp
==============================================================================
--- trunk/boost/math/special_functions/binomial.hpp (original)
+++ trunk/boost/math/special_functions/binomial.hpp 2009-05-28 04:52:05 EDT (Thu, 28 May 2009)
@@ -19,6 +19,7 @@
 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)

Modified: trunk/boost/math/special_functions/factorials.hpp
==============================================================================
--- trunk/boost/math/special_functions/factorials.hpp (original)
+++ trunk/boost/math/special_functions/factorials.hpp 2009-05-28 04:52:05 EDT (Thu, 28 May 2009)
@@ -30,6 +30,7 @@
 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 @@
 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 @@
 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 @@
 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;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk