$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r79438 - in trunk: boost/math/special_functions libs/math/test
From: john_at_[hidden]
Date: 2012-07-12 05:51:33
Author: johnmaddock
Date: 2012-07-12 05:51:32 EDT (Thu, 12 Jul 2012)
New Revision: 79438
URL: http://svn.boost.org/trac/boost/changeset/79438
Log:
Allow fpclassify and friends to be used with integer types via the usual promotion mechanism.
Fixes #6517.
Text files modified: 
   trunk/boost/math/special_functions/fpclassify.hpp |    16 ++++++++++------                        
   trunk/libs/math/test/test_classify.cpp            |    28 +++++++++++++++++-----------            
   2 files changed, 27 insertions(+), 17 deletions(-)
Modified: trunk/boost/math/special_functions/fpclassify.hpp
==============================================================================
--- trunk/boost/math/special_functions/fpclassify.hpp	(original)
+++ trunk/boost/math/special_functions/fpclassify.hpp	2012-07-12 05:51:32 EDT (Thu, 12 Jul 2012)
@@ -249,12 +249,13 @@
 {
    typedef typename detail::fp_traits<T>::type traits;
    typedef typename traits::method method;
+   typedef typename tools::promote_args<T>::type value_type;
 #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
    if(std::numeric_limits<T>::is_specialized && detail::is_generic_tag_false(static_cast<method*>(0)))
-      return detail::fpclassify_imp(t, detail::generic_tag<true>());
-   return detail::fpclassify_imp(t, method());
+      return detail::fpclassify_imp(static_cast<value_type>(t), detail::generic_tag<true>());
+   return detail::fpclassify_imp(static_cast<value_type>(t), method());
 #else
-   return detail::fpclassify_imp(t, method());
+   return detail::fpclassify_imp(static_cast<value_type>(t), method());
 #endif
 }
 
@@ -312,7 +313,8 @@
    typedef typename detail::fp_traits<T>::type traits;
    typedef typename traits::method method;
    typedef typename boost::is_floating_point<T>::type fp_tag;
-   return detail::isfinite_impl(x, method());
+   typedef typename tools::promote_args<T>::type value_type;
+   return detail::isfinite_impl(static_cast<value_type>(x), method());
 }
 
 //------------------------------------------------------------------------------
@@ -371,7 +373,8 @@
    typedef typename detail::fp_traits<T>::type traits;
    typedef typename traits::method method;
    typedef typename boost::is_floating_point<T>::type fp_tag;
-   return detail::isnormal_impl(x, method());
+   typedef typename tools::promote_args<T>::type value_type;
+   return detail::isnormal_impl(static_cast<value_type>(x), method());
 }
 
 //------------------------------------------------------------------------------
@@ -448,7 +451,8 @@
    typedef typename detail::fp_traits<T>::type traits;
    typedef typename traits::method method;
    typedef typename boost::is_floating_point<T>::type fp_tag;
-   return detail::isinf_impl(x, method());
+   typedef typename tools::promote_args<T>::type value_type;
+   return detail::isinf_impl(static_cast<value_type>(x), method());
 }
 
 //------------------------------------------------------------------------------
Modified: trunk/libs/math/test/test_classify.cpp
==============================================================================
--- trunk/libs/math/test/test_classify.cpp	(original)
+++ trunk/libs/math/test/test_classify.cpp	2012-07-12 05:51:32 EDT (Thu, 12 Jul 2012)
@@ -14,7 +14,7 @@
 #include <boost/test/test_exec_monitor.hpp>
 
 #ifdef _MSC_VER
-#pragma warning(disable: 4127) //  conditional expression is constant
+#pragma warning(disable: 4127 4146) //  conditional expression is constant
 #endif
 
 const char* method_name(const boost::math::detail::native_tag&)
@@ -83,16 +83,19 @@
       BOOST_CHECK_EQUAL((::boost::math::isnormal)(t), true);
       BOOST_CHECK_EQUAL((::boost::math::isnormal)(-t), true);
       t = (std::numeric_limits<T>::min)();
-      BOOST_CHECK_EQUAL((::boost::math::fpclassify)(t), (int)FP_NORMAL);
-      BOOST_CHECK_EQUAL((::boost::math::fpclassify)(-t), (int)FP_NORMAL);
-      BOOST_CHECK_EQUAL((::boost::math::isfinite)(t), true);
-      BOOST_CHECK_EQUAL((::boost::math::isfinite)(-t), true);
-      BOOST_CHECK_EQUAL((::boost::math::isinf)(t), false);
-      BOOST_CHECK_EQUAL((::boost::math::isinf)(-t), false);
-      BOOST_CHECK_EQUAL((::boost::math::isnan)(t), false);
-      BOOST_CHECK_EQUAL((::boost::math::isnan)(-t), false);
-      BOOST_CHECK_EQUAL((::boost::math::isnormal)(t), true);
-      BOOST_CHECK_EQUAL((::boost::math::isnormal)(-t), true);
+      if(t != 0)
+      {
+         BOOST_CHECK_EQUAL((::boost::math::fpclassify)(t), (int)FP_NORMAL);
+         BOOST_CHECK_EQUAL((::boost::math::fpclassify)(-t), (int)FP_NORMAL);
+         BOOST_CHECK_EQUAL((::boost::math::isfinite)(t), true);
+         BOOST_CHECK_EQUAL((::boost::math::isfinite)(-t), true);
+         BOOST_CHECK_EQUAL((::boost::math::isinf)(t), false);
+         BOOST_CHECK_EQUAL((::boost::math::isinf)(-t), false);
+         BOOST_CHECK_EQUAL((::boost::math::isnan)(t), false);
+         BOOST_CHECK_EQUAL((::boost::math::isnan)(-t), false);
+         BOOST_CHECK_EQUAL((::boost::math::isnormal)(t), true);
+         BOOST_CHECK_EQUAL((::boost::math::isnormal)(-t), true);
+      }
    }
    if(std::numeric_limits<T>::has_denorm)
    {
@@ -273,6 +276,9 @@
    test_classify((long double)(0), "long double");
    test_classify((boost::math::concepts::real_concept)(0), "real_concept");
 #endif
+   // We should test with integer types as well:
+   test_classify(int(0), "int");
+   test_classify(unsigned(0), "unsigned");
   return 0;
 }