Boost logo

Boost :

From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-08-26 13:23:13


Actually, I am trying to improve my serialization of mersenne_twister, and
the previous test was a useless test to debug it.

I have gotten a little further now, I think I have the "save" correct. I'm
not sure about "load". I have been trying to follow the example of
collections_load_imp. It uses "stack_construct" and
"reset_object_address". I'm having trouble finding where the use of these
is documented and whether I need them for my case.

So far the mersenne_twister relevant code would look like:

(In MT, compute() returns the elements we want to save, and to restore we
just load the array 'x' directly.)

  template<class Archive>
  inline void save (Archive &ar, const unsigned int) const {
    for (int j = 0; j < state_size; ++j) {
      UIntType x = compute (j);
      ar << boost::serialization::make_nvp("item", const_cast<const
UIntType&>(x));
    }
  }

  template<class Archive>
  inline void load (Archive &ar, const unsigned int) {
    for (int j = 0; j < state_size; ++j) {
      stack_contruct<Archive, UIntType> t (ar);
      ar >> boost::serialization::make_nvp ("item", t.reference());
      x[j] = t.reference();
      ar.reset_object_address (???
     }
    i = state_size;
  }

  template<class Archive>
  void serialize(Archive & ar, const unsigned int file_version) {
    boost::serialization::split_member(ar, *this, file_version);
  }


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