Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r83537 - in trunk/boost/math: constants special_functions/detail tools
From: john_at_[hidden]
Date: 2013-03-24 08:01:59


Author: johnmaddock
Date: 2013-03-24 08:01:58 EDT (Sun, 24 Mar 2013)
New Revision: 83537
URL: http://svn.boost.org/trac/boost/changeset/83537

Log:
Make use of lexical_cast (and hence multiprecision support) dependent on there being an iostreams lib. Should allow use on embedded platforms, especially WinCE.
Fixes #8327.
Text files modified:
   trunk/boost/math/constants/constants.hpp | 7 +++++++
   trunk/boost/math/special_functions/detail/unchecked_factorial.hpp | 20 ++++++++++++++++++++
   trunk/boost/math/tools/big_constant.hpp | 4 ++++
   trunk/boost/math/tools/config.hpp | 6 ++++++
   4 files changed, 37 insertions(+), 0 deletions(-)

Modified: trunk/boost/math/constants/constants.hpp
==============================================================================
--- trunk/boost/math/constants/constants.hpp (original)
+++ trunk/boost/math/constants/constants.hpp 2013-03-24 08:01:58 EDT (Sun, 24 Mar 2013)
@@ -14,7 +14,9 @@
 #pragma warning(push)
 #pragma warning(disable: 4127 4701)
 #endif
+#ifndef BOOST_MATH_NO_LEXICAL_CAST
 #include <boost/lexical_cast.hpp>
+#endif
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
@@ -124,7 +126,12 @@
       template <class Real>
       Real convert_from_string(const char* p, const mpl::false_&)
       {
+#ifdef BOOST_MATH_NO_LEXICAL_CAST
+ // This function should not compile, we don't have the necesary functionality to support it:
+ BOOST_STATIC_ASSERT(sizeof(Real) == 0);
+#else
          return boost::lexical_cast<Real>(p);
+#endif
       }
       template <class Real>
       const char* convert_from_string(const char* p, const mpl::true_&)

Modified: trunk/boost/math/special_functions/detail/unchecked_factorial.hpp
==============================================================================
--- trunk/boost/math/special_functions/detail/unchecked_factorial.hpp (original)
+++ trunk/boost/math/special_functions/detail/unchecked_factorial.hpp 2013-03-24 08:01:58 EDT (Sun, 24 Mar 2013)
@@ -15,7 +15,9 @@
 #pragma warning(push) // Temporary until lexical cast fixed.
 #pragma warning(disable: 4127 4701)
 #endif
+#ifndef BOOST_MATH_NO_LEXICAL_CAST
 #include <boost/lexical_cast.hpp>
+#endif
 #ifdef BOOST_MSVC
 #pragma warning(pop)
 #endif
@@ -279,6 +281,8 @@
       value = ::boost::math::max_factorial<long double>::value);
 };
 
+#ifndef BOOST_MATH_NO_LEXICAL_CAST
+
 template <class T>
 inline T unchecked_factorial(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
 {
@@ -403,6 +407,22 @@
    BOOST_STATIC_CONSTANT(unsigned, value = 100);
 };
 
+#else // BOOST_MATH_NO_LEXICAL_CAST
+
+template <class T>
+inline T unchecked_factorial(unsigned i BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(T))
+{
+ return 1;
+}
+
+template <class T>
+struct max_factorial
+{
+ BOOST_STATIC_CONSTANT(unsigned, value = 0);
+};
+
+#endif
+
 #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
 template <class T>
 const unsigned max_factorial<T>::value;

Modified: trunk/boost/math/tools/big_constant.hpp
==============================================================================
--- trunk/boost/math/tools/big_constant.hpp (original)
+++ trunk/boost/math/tools/big_constant.hpp 2013-03-24 08:01:58 EDT (Sun, 24 Mar 2013)
@@ -8,7 +8,9 @@
 #define BOOST_MATH_TOOLS_BIG_CONSTANT_HPP
 
 #include <boost/math/tools/config.hpp>
+#ifndef BOOST_MATH_NO_LEXICAL_CAST
 #include <boost/lexical_cast.hpp>
+#endif
 #include <boost/type_traits/is_convertible.hpp>
 
 namespace boost{ namespace math{
@@ -25,11 +27,13 @@
 {
    return static_cast<T>(v);
 }
+#ifndef BOOST_MATH_NO_LEXICAL_CAST
 template <class T>
 inline T make_big_value(long double, const char* s, mpl::false_ const&, mpl::false_ const&)
 {
    return boost::lexical_cast<T>(s);
 }
+#endif
 template <class T>
 inline BOOST_CONSTEXPR const char* make_big_value(long double, const char* s, mpl::false_ const&, mpl::true_ const&)
 {

Modified: trunk/boost/math/tools/config.hpp
==============================================================================
--- trunk/boost/math/tools/config.hpp (original)
+++ trunk/boost/math/tools/config.hpp 2013-03-24 08:01:58 EDT (Sun, 24 Mar 2013)
@@ -217,6 +217,12 @@
 //
 # define BOOST_MATH_USE_FLOAT128
 #endif
+//
+// Check for WinCE with no iostream support:
+//
+#if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
+# define BOOST_MATH_NO_LEXICAL_CAST
+#endif
 
 //
 // Helper macro for controlling the FP behaviour:


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