4

I want to serialize a Reconstruction class in a library called theia. The class Reconstruction does have a serialize function:

friend class cereal::access;
  template <class Archive>
  void serialize(Archive& ar) {  // NOLINT
    ar(next_track_id_,
       next_view_id_,
       view_name_to_id_,
       views_,
       tracks_);
  }

The serialization already in place works fine like this:

Reconstruction estimated_reconstruction;

[...]
std::ofstream output_writer(output_file, std::ios::out | std::ios::binary);
cereal::PortableBinaryOutputArchive output_archive(output_writer);
 output_archive(estimated_reconstruction);

But when I change it to an XMLOutputArchive (adding the necessary #include) it doesn't work anymore!

Reconstruction estimated_reconstruction;
[...]

std::ofstream output_writer(output_file, std::ios::out);
cereal::XMLOutputArchive output_archive(output_writer);
output_archive(estimated_reconstruction);

The error is the following one:

[...]

error: static assertion failed: cereal could not find any output serialization functions for the provided type and archive combination.

 Types must either have a serialize function, load/save pair, or load_minimal/save_minimal pair (you may not mix these).
 Serialize functions generally have the following signature:

 template<class Archive>
   void serialize(Archive & ar)
   {
     ar( member1, member2, member3 );
   }
Llopeth
  • 406
  • 5
  • 11
  • 3
    To see where the problem is coming from, try serializing the class members one at a time. You can then debug that individual class with XML serialization. – Azoth Jan 30 '16 at 00:33
  • Does the compiler create any additional output around this error? I have found I get this error when I forget to add a header that includes my Load/Save functions, and typically the place I need to add that header is indicated at the end of a long chain of "see reference to:". In visual studio, this appears in the output window. – MatrixManAtYrService Jan 04 '17 at 23:28

0 Answers0