Boost logo

Boost Users :

From: Meik (yuki_meik_at_[hidden])
Date: 2019-12-21 21:09:19


Hello,

I am new to C++ and thus new to Boost. My goal is to serialize a class
containing multiple std::valarrays with primitives as content.

The code I wrote to achieve that(minimal example to reproduce):

 Â Â Â  #include <iostream>
 Â Â Â  #include <boost/archive/text_oarchive.hpp>

 Â Â Â  class A {
 Â Â Â Â Â Â Â  valarray<int> member_one;
 Â Â Â Â Â Â Â  valarray<float> member_two;
 Â Â Â Â Â Â Â  friend class boost::serialization::access;

 Â Â Â Â Â Â Â  template<class Archive>
 Â Â Â Â Â Â Â  void serialize(Archive &ar, const unsigned int version){
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  ar & member_one;
 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â  ar & member_two
 Â Â Â Â Â Â Â  }
 Â Â Â  }
 Â Â Â  int main(int argc, char* argv[]) {
 Â Â Â Â Â Â Â  boost::archive::text_oarchive oarchive(cout);
 Â Â Â Â Â Â Â  oarchive << p;
 Â Â Â Â Â Â Â  return 0;
 Â Â Â  }

When compiling this, the following error is given:

error: class std::valarray<int> has no member names serialize

I'd appreciate if you could let me know how to correctly serialize said
std::valarray.

Kind regards,
Meik S.

||



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