Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50274 - in trunk/boost/math/special_functions: . detail
From: john_at_[hidden]
Date: 2008-12-15 04:31:45


Author: johnmaddock
Date: 2008-12-15 04:31:44 EST (Mon, 15 Dec 2008)
New Revision: 50274
URL: http://svn.boost.org/trac/boost/changeset/50274

Log:
Reorganise std::fpclassify usage so that functions are only declared if they're used: otherwise compilers can issue an error regarding std::fpclassify usage, even though the template is never instantiated.
Text files modified:
   trunk/boost/math/special_functions/detail/fp_traits.hpp | 11 +++++++----
   trunk/boost/math/special_functions/fpclassify.hpp | 23 ++++++++++++++---------
   2 files changed, 21 insertions(+), 13 deletions(-)

Modified: trunk/boost/math/special_functions/detail/fp_traits.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/fp_traits.hpp (original)
+++ trunk/boost/math/special_functions/detail/fp_traits.hpp 2008-12-15 04:31:44 EST (Mon, 15 Dec 2008)
@@ -537,13 +537,16 @@
 
 // fp_traits is a type switch that selects the right fp_traits_non_native
 
-template<class T> struct fp_traits
-{
 #if (defined(BOOST_MATH_USE_C99) && !(defined(__GNUC__) && (__GNUC__ < 4))) \
    && !defined(__hpux) \
    && !defined(__DECCXX)\
- && !defined(__osf__)\
- && !(defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__))
+ && !defined(__osf__)
+# define BOOST_MATH_USE_STD_FPCLASSIFY
+#endif
+
+template<class T> struct fp_traits
+{
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
     typedef typename select_native<T>::type type;
 #else
     typedef BOOST_DEDUCED_TYPENAME size_to_precision<sizeof(T), ::boost::is_floating_point<T>::value>::type precision;

Modified: trunk/boost/math/special_functions/fpclassify.hpp
==============================================================================
--- trunk/boost/math/special_functions/fpclassify.hpp (original)
+++ trunk/boost/math/special_functions/fpclassify.hpp 2008-12-15 04:31:44 EST (Mon, 15 Dec 2008)
@@ -110,11 +110,13 @@
 
 namespace detail{
 
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
 template <class T>
 inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const native_tag&)
 {
    return (std::fpclassify)(t);
 }
+#endif
 
 template <class T>
 inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const generic_tag<true>&)
@@ -224,7 +226,7 @@
    return FP_NAN;
 }
 
-#if defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
+#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
 template <>
 inline int fpclassify_imp<long double> BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
 {
@@ -250,11 +252,13 @@
 
 namespace detail {
 
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
     template<class T>
     inline bool isfinite_impl(T x, native_tag const&)
     {
         return (std::isfinite)(x);
     }
+#endif
 
     template<class T>
     inline bool isfinite_impl(T x, generic_tag<true> const&)
@@ -284,7 +288,7 @@
         return a != traits::exponent;
     }
 
-#if defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
+#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
 template <>
 inline bool isfinite_impl<long double> BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
 {
@@ -307,11 +311,13 @@
 
 namespace detail {
 
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
     template<class T>
     inline bool isnormal_impl(T x, native_tag const&)
     {
         return (std::isnormal)(x);
     }
+#endif
 
     template<class T>
     inline bool isnormal_impl(T x, generic_tag<true> const&)
@@ -341,7 +347,7 @@
         return (a != 0) && (a < traits::exponent);
     }
 
-#if defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
+#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
 template <>
 inline bool isnormal_impl<long double> BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
 {
@@ -364,11 +370,13 @@
 
 namespace detail {
 
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
     template<class T>
     inline bool isinf_impl(T x, native_tag const&)
     {
         return (std::isinf)(x);
     }
+#endif
 
     template<class T>
     inline bool isinf_impl(T x, generic_tag<true> const&)
@@ -415,7 +423,7 @@
         return x == 0;
     }
 
-#if defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
+#if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
 template <>
 inline bool isinf_impl<long double> BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
 {
@@ -438,11 +446,13 @@
 
 namespace detail {
 
+#ifdef BOOST_MATH_USE_STD_FPCLASSIFY
     template<class T>
     inline bool isnan_impl(T x, native_tag const&)
     {
         return (std::isnan)(x);
     }
+#endif
 
     template<class T>
     inline bool isnan_impl(T x, generic_tag<true> const&)
@@ -512,8 +522,3 @@
 
 #endif // BOOST_MATH_FPCLASSIFY_HPP
 
-
-
-
-
-


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