我正在尝试使用 boost 序列化序列化特征矩阵。我已经看到了这个问题并尝试使用该解决方案,但是我遇到了奇怪的编译器错误。
我有一个shared_ptr
to aMatrixXd
并尝试将其序列化如下:
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "utils.hpp"
boost::shared_ptr<std::map<int, boost::shared_ptr<Eigen::MatrixXd> > > class_to_inv_cov_mat;
template<class Archive>
void serialize(Archive& ar, const unsigned int version){
ar & BOOST_SERIALIZATION_NVP(class_to_inv_cov_mat);
}
我也有 utils.hpp 其中包括:
namespace boost {
template<class Archive, typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
inline void serialize(
Archive & ar,
Eigen::Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> & t,
const unsigned int file_version
)
{
for(size_t i=0; i<t.size(); i++)
ar & t.data()[i];
}
}
当我编译时,我收到以下错误:
/usr/include/boost/archive/detail/oserializer.hpp:148:5: instantiated from ‘void boost::archive::detail::oserializer<Archive, T>::save_object_data(boost::archive::detail::basic_oarchive&, const void*) const [with Archive = boost::archive::xml_oarchive, T = Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001>]’
../src/Main.cpp:357:1: instantiated from here
/usr/include/boost/archive/basic_xml_oarchive.hpp:92:9: error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::serialization::is_wrapper<const double>::************)’
我不懂这啥意思?