Boost logo

Boost Users :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2008-07-11 21:18:51


Jeffrey A. Edlund wrote:

> If I'm using g++ then I can just use operator<< and operator>> to save
> and load the state of the random number generator. Unfortunately I
> also need to compile this code on MSVC++ 8.0. Using MSVC++ 8.0
> BOOST_NO_MEMBER_TEMPLATE_FRIENDS is defined which removes those
> operators. Is there some way to do this without modifying
> mersenne_twister.hpp or doing something crazy like #define private
> public?
>
> Thanks,
>
> Jeffrey
diff -r 45d1d3143fe3 boost/random/mersenne_twister.hpp
--- a/boost/random/mersenne_twister.hpp Tue Dec 11 13:26:15 2007 -0500
+++ b/boost/random/mersenne_twister.hpp Mon Dec 17 06:51:24 2007 -0500
@@ -27,6 +27,8 @@
 #include <boost/random/linear_congruential.hpp>
 #include <boost/detail/workaround.hpp>
 #include <boost/random/detail/ptr_helper.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/nvp.hpp>
 
 namespace boost {
 namespace random {
@@ -152,6 +154,16 @@ public:
     mt.i = mt.state_size;
     return is;
   }
+
+ friend class boost::serialization::access;
+
+ // Serialization
+ template<class Archive>
+ void serialize(Archive & ar, const unsigned int /* file_version */){
+ ar & serialization::make_nvp ("i", i);
+ ar & serialization::make_nvp ("x", x);
+ }
+
 #endif
 
   friend bool operator==(const mersenne_twister& x, const mersenne_twister&
y)


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net