0

I am trying to serialize an instance of typle

std::vector<std::unordered_map<std::string, arma::mat>>

To so, I used the same approach of mlpack (also explained here How to serialize armadillo's vector) and copied the files mat_extra_bones.hpp and mat_extra_meat.hpp from https://github.com/mlpack/mlpack/tree/master/src/mlpack/core/arma_extend

However, when I compile the MWE below, I get the following error

 error: ‘class std::unordered_map<std::__cxx11::basic_string<char>, arma::Mat<double> >’ has no member named ‘serialize’

here the MWE

#include <armadillo>
#define ARMA_EXTRA_MAT_PROTO mat_extra_bones.hpp
#define ARMA_EXTRA_MAT_MEAT mat_extra_meat.hpp
#include <unordered_map>
#include <vector>
#include <string>
#include <boost/serialization/boost_unordered_map.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>


int main() {
  std::vector<std::unordered_map<std::string, arma::mat>> iters(2);
  std::unordered_map<std::string, arma::mat> iter1;
  std::unordered_map<std::string, arma::mat> iter2;

  iter1["a"] = arma::mat(3, 3, arma::fill::eye);
  iter1["b"] = arma::vec(3, arma::fill::ones);


  iter2["a"] = arma::mat(3, 3, arma::fill::eye);
  iter2["b"] = arma::vec(3, arma::fill::ones);
  iter2["c"] = arma::vec(3, arma::fill::zeros);

  iters[0] = iter1;
  iters[1] = iter2;

  std::ofstream ofs("save.dat", std::ios::binary);
  boost::archive::binary_oarchive oa(ofs);
  oa<<iters;
}
mariob6
  • 469
  • 1
  • 6
  • 16

0 Answers0