I have the following template class:
#include <map>
#include <boost/array.hpp>
#include <boost/serialization/map.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/multiprecision/gmp.hpp>
template <class T>
class A {
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & a;
}
public:
T a;
};
that I use to create a map.
map<A<boost::array<int,2> >, int> mmm;
I can use the header files provided by boost to serialize/deserialize this code using:
ifstream ifs("filename");
boost::archive::text_iarchive iarch(ifs);
boost::serialization::load<boost::archive::text_iarchive,int,A<boost::array<int,2> > >(iarch,mmm,1);
Question: I would like to use boost::multiprecision::mpq_rational
instead of int
inside the array. However I get a long error with the main complaint being that gmp_backend does not have a serialize method:
....
/usr/local/include/boost/serialization/access.hpp:118:9: error: ‘struct boost::multiprecision::backends::gmp_rational’ has no member named ‘serialize’
t.serialize(ar, file_version);
^
Is there an easy fix using boost/serialization/map.hpp with mpq_rational?
Thanks,
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…