Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-07-30 20:10:38


I'm applying the following patch to Boost.Random to improve support
for broken compilers, FYI. Squawk now or forever hold your peace! ;->

cvs server: Diffing boost/random
Index: boost/random/mersenne_twister.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/random/mersenne_twister.hpp,v
retrieving revision 1.13
diff -w -u -r1.13 mersenne_twister.hpp
--- boost/random/mersenne_twister.hpp 18 Jul 2003 20:45:18 -0000 1.13
+++ boost/random/mersenne_twister.hpp 31 Jul 2003 01:09:58 -0000
@@ -31,6 +31,7 @@
 #include <boost/cstdint.hpp>
 #include <boost/random/linear_congruential.hpp>
 # include <boost/detail/workaround.hpp>
+#include <boost/random/detail/ptr_helper.hpp>
 
 namespace boost {
 namespace random {
@@ -293,5 +294,7 @@
   7,0x9d2c5680,15,0xefc60000,18, 3346425566U> mt19937;
 
 } // namespace boost
+
+BOOST_RANDOM_PTR_HELPER_SPEC(boost::mt19937)
 
 #endif // BOOST_RANDOM_MERSENNE_TWISTER_HPP
cvs server: Diffing boost/random/detail
Index: boost/random/detail/ptr_helper.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/random/detail/ptr_helper.hpp,v
retrieving revision 1.1
diff -w -u -r1.1 ptr_helper.hpp
--- boost/random/detail/ptr_helper.hpp 7 Jul 2003 20:57:14 -0000 1.1
+++ boost/random/detail/ptr_helper.hpp 31 Jul 2003 01:09:58 -0000
@@ -63,4 +63,37 @@
 } // namespace random
 } // namespace boost
 
+//
+// BOOST_RANDOM_PTR_HELPER_SPEC --
+//
+// Helper macro for broken compilers defines specializations of
+// ptr_helper.
+//
+#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
+# define BOOST_RANDOM_PTR_HELPER_SPEC(T) \
+namespace boost { namespace random { namespace detail { \
+template<> \
+struct ptr_helper<T&> \
+{ \
+ typedef T value_type; \
+ typedef T& reference_type; \
+ typedef T& rvalue_type; \
+ static reference_type ref(T& r) { return r; } \
+ static const T& ref(const T& r) { return r; } \
+}; \
+ \
+template<> \
+struct ptr_helper<T*> \
+{ \
+ typedef T value_type; \
+ typedef T& reference_type; \
+ typedef T* rvalue_type; \
+ static reference_type ref(T * p) { return *p; } \
+ static const T& ref(const T * p) { return *p; } \
+}; \
+}}}
+#else
+# define BOOST_RANDOM_PTR_HELPER_SPEC(T)
+#endif
+
 #endif // BOOST_RANDOM_DETAIL_PTR_HELPER_HPP

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk