小编Say*_*yid的帖子

是否可以对托管类使用boost :: serialization?

我们有很多使用boost :: serialization完美序列化的本机c ++类.

现在我们想将一些成员字段更改为property,因此我们可以在PropertyGrids中使用它们.当我们将类定义更改为ref class X时,我们得到了大量的编译错误:

#1: error C2893: Failed to specialize function template 'boost::archive::text_oarchive &boost::archive::detail::interface_oarchive<Archive>::operator <<(T &)' d:\someAddress\someFile.cpp 58

#2: error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::_Smanip<_Arg> &)' : could not deduce template argument for 'std::basic_ostream<_Elem,_Traits> &' from 'boost::archive::text_oarchive' d:\someAddress\someFile.cpp 58

我们这里有很多小类,所以为每个类编写一个包装器会很麻烦!

这是我们使用的示例类:

ref class gps_position2
{
public:
    template<class Archive>
    void serialize(Archive & ar, const unsigned int version)
    {
        ar & seconds;
    }
public:
    gps_position(){};
    gps_position(float s)
    {
        this->seconds = …
Run Code Online (Sandbox Code Playgroud)

boost managed-c++ c++-cli boost-serialization visual-c++

7
推荐指数
1
解决办法
692
查看次数