Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-04-16 07:57:30


Author: johnmaddock
Date: 2008-04-16 07:57:29 EDT (Wed, 16 Apr 2008)
New Revision: 44452
URL: http://svn.boost.org/trac/boost/changeset/44452

Log:
Reinstated real_cast to that STLPort tests can pass.
Text files modified:
   trunk/boost/math/concepts/real_concept.hpp | 54 ++++++++++++++++++++++++++++++++++++++++
   1 files changed, 54 insertions(+), 0 deletions(-)

Modified: trunk/boost/math/concepts/real_concept.hpp
==============================================================================
--- trunk/boost/math/concepts/real_concept.hpp (original)
+++ trunk/boost/math/concepts/real_concept.hpp 2008-04-16 07:57:29 EDT (Wed, 16 Apr 2008)
@@ -27,6 +27,9 @@
 #include <boost/math/special_functions/modf.hpp>
 #include <boost/math/tools/precision.hpp>
 #include <boost/math/policies/policy.hpp>
+#if defined(__SGI_STL_PORT)
+# include <boost/math/tools/real_cast.hpp>
+#endif
 #include <ostream>
 #include <istream>
 #include <cmath>
@@ -392,6 +395,57 @@
 
 #endif
 
+#if defined(__SGI_STL_PORT)
+//
+// We shouldn't really need these type casts any more, but there are some
+// STLport iostream bugs we work around by using them....
+//
+namespace tools
+{
+// real_cast converts from T to integer and narrower floating-point types.
+
+// Convert from T to integer types.
+
+template <>
+inline unsigned int real_cast<unsigned int, concepts::real_concept>(concepts::real_concept r)
+{
+ return static_cast<unsigned int>(r.value());
+}
+
+template <>
+inline int real_cast<int, concepts::real_concept>(concepts::real_concept r)
+{
+ return static_cast<int>(r.value());
+}
+
+template <>
+inline long real_cast<long, concepts::real_concept>(concepts::real_concept r)
+{
+ return static_cast<long>(r.value());
+}
+
+// Converts from T to narrower floating-point types, float, double & long double.
+
+template <>
+inline float real_cast<float, concepts::real_concept>(concepts::real_concept r)
+{
+ return static_cast<float>(r.value());
+}
+template <>
+inline double real_cast<double, concepts::real_concept>(concepts::real_concept r)
+{
+ return static_cast<double>(r.value());
+}
+template <>
+inline long double real_cast<long double, concepts::real_concept>(concepts::real_concept r)
+{
+ return r.value();
+}
+
+} // STLPort
+
+#endif
+
 } // namespace math
 } // namespace boost
 


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