|
Boost-Commit : |
From: john_at_[hidden]
Date: 2007-08-28 08:34:15
Author: johnmaddock
Date: 2007-08-28 08:34:14 EDT (Tue, 28 Aug 2007)
New Revision: 39031
URL: http://svn.boost.org/trac/boost/changeset/39031
Log:
Updated isnan so that it works even when the system does a "#define isnan isnan".
Updated Jamfiles to reflect new file names, and suppress some more warnings.
Text files modified:
sandbox/math_toolkit/boost/math/special_functions/fpclassify.hpp | 37 ++++++++++++++++++++++---------------
sandbox/math_toolkit/libs/math/example/Jamfile.v2 | 3 ++-
sandbox/math_toolkit/libs/math/test/Jamfile.v2 | 3 ++-
3 files changed, 26 insertions(+), 17 deletions(-)
Modified: sandbox/math_toolkit/boost/math/special_functions/fpclassify.hpp
==============================================================================
--- sandbox/math_toolkit/boost/math/special_functions/fpclassify.hpp (original)
+++ sandbox/math_toolkit/boost/math/special_functions/fpclassify.hpp 2007-08-28 08:34:14 EDT (Tue, 28 Aug 2007)
@@ -53,23 +53,24 @@
#endif
-namespace boost{ namespace math{
-
-namespace detail{
+namespace boost{
#if defined(BOOST_HAS_FPCLASSIFY) || defined(isnan)
+//
+// This must not be located in any namespace under boost::math
+// otherwise we can get into an infinite loop if isnan is
+// a #define for "isnan" !
+//
+namespace math_detail{
template <class T>
inline bool is_nan_helper(T t, const boost::true_type&)
{
-#ifdef BOOST_HAS_FPCLASSIFY
- if( BOOST_FPCLASSIFY_PREFIX fpclassify(t) == FP_NAN)
- return true;
-#elif defined(isnan)
- if(isnan(t))
- return true;
+#ifdef isnan
+ return isnan(t);
+#else // BOOST_HAS_FPCLASSIFY
+ return (BOOST_FPCLASSIFY_PREFIX fpclassify(t) == FP_NAN);
#endif
- return false;
}
template <class T>
@@ -78,17 +79,23 @@
return false;
}
+}
+
#endif // defined(BOOST_HAS_FPCLASSIFY) || defined(isnan)
+namespace math{
+
+namespace detail{
+
template <class T>
inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const mpl::true_&)
{
// whenever possible check for Nan's first:
#ifdef BOOST_HAS_FPCLASSIFY
- if(detail::is_nan_helper(t, ::boost::is_floating_point<T>()))
+ if(::boost::math_detail::is_nan_helper(t, ::boost::is_floating_point<T>()))
return FP_NAN;
#elif defined(isnan)
- if(detail::is_nan_helper(t, ::boost::is_floating_point<T>()))
+ if(boost::math_detail::is_nan_helper(t, ::boost::is_floating_point<T>()))
return FP_NAN;
#elif defined(_MSC_VER) || defined(__BORLANDC__)
if(::_isnan(boost::math::tools::real_cast<double>(t)))
@@ -204,9 +211,9 @@
return (::boost::math::fpclassify)(t) == FP_NAN;
}
#ifdef isnan
-template <> inline bool isnan BOOST_NO_MACRO_EXPAND<float>(float t){ return isnan(t); }
-template <> inline bool isnan BOOST_NO_MACRO_EXPAND<double>(double t){ return isnan(t); }
-template <> inline bool isnan BOOST_NO_MACRO_EXPAND<long double>(long double t){ return isnan(t); }
+template <> inline bool isnan BOOST_NO_MACRO_EXPAND<float>(float t){ return ::boost::math_detail::is_nan_helper(t, boost::true_type()); }
+template <> inline bool isnan BOOST_NO_MACRO_EXPAND<double>(double t){ return ::boost::math_detail::is_nan_helper(t, boost::true_type()); }
+template <> inline bool isnan BOOST_NO_MACRO_EXPAND<long double>(long double t){ return ::boost::math_detail::is_nan_helper(t, boost::true_type()); }
#elif defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false'
Modified: sandbox/math_toolkit/libs/math/example/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/example/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/example/Jamfile.v2 2007-08-28 08:34:14 EDT (Tue, 28 Aug 2007)
@@ -34,7 +34,7 @@
run error_policies_example.cpp ;
run error_policy_example.cpp ;
run f_test.cpp ;
-run neg_binomial_confidence_limits.cpp ;
+run neg_binom_confidence_limits.cpp ;
run neg_binomial_sample_sizes.cpp ;
run negative_binomial_construction_examples.cpp ;
run negative_binomial_example1.cpp ;
@@ -73,3 +73,4 @@
+
Modified: sandbox/math_toolkit/libs/math/test/Jamfile.v2
==============================================================================
--- sandbox/math_toolkit/libs/math/test/Jamfile.v2 (original)
+++ sandbox/math_toolkit/libs/math/test/Jamfile.v2 2007-08-28 08:34:14 EDT (Tue, 28 Aug 2007)
@@ -11,7 +11,7 @@
: requirements
<toolset>gcc:<cxxflags>-Wno-missing-braces
<toolset>darwin:<cxxflags>-Wno-missing-braces
- <toolset>acc:<cxxflags>+W2068,2461,2236,4070
+ <toolset>acc:<cxxflags>+W2068,2461,2236,4070,4069
<toolset>intel:<cxxflags>-Qwd264,239
<toolset>intel:<cxxflags>/nologo
<toolset>intel:<linkflags>/nologo
@@ -188,3 +188,4 @@
+
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