【问题标题】:In Boost serialization,boost_shared pointer does not compile.. give error在Boost序列化中,boost_shared指针不编译..给出错误
【发布时间】:2014-03-22 00:39:42
【问题描述】:

我正在尝试使用 boost 序列化共享指针,但它给出了错误: 错误1错误C4308:负整数常量转换为无符号类型c:\users\allwork\hope\lib\boost_1_55_0\boost\mpl\print.hpp 51 1 Input

我什至尝试了链接中给出的解决方案 - https://stackoverflow.com/questions/22409755/boost-serialization-fails-gives-compile-time-error-c4308 但问题仍然存在。

如果我评论行 - " ar & MyStruct; " 错误消失。请让我知道当前代码存在哪些错误或问题。

下面是代码:

// MyStruct.hpp 文件

struct MyStruct
{
std::string rollno;
std::string address;
***boost::shared_ptr<MyStruct> Mydata;*** 

private:
friend class boost::serialization::access;
template
void serialize(Archive &ar, const unsigned int version)
{
ar & rollno;
ar & address;
ar & Mydata; 
} 

public:
MyStruct(void);
MyStruct(const parameter_strings & parms);

virtual ~MyStruct(void);
};
}

// MyStruct.cpp file

MyStruct::MyStruct(void)
{
}

MyStruct::~MyStruct(void)
{
}

MyStruct::MyStruct(const parameter_strings & parms)
{
// implementation 
}

BOOST_CLASS_EXPORT_IMPLEMENT(MyStruct);   BOOST_CLASS_IMPLEMENTATION(MyStruct,boost::serialization::object_serializable);
BOOST_CLASS_TRACKING(MyStruct,boost::serialization::track_selectively);

【问题讨论】:

    标签: c++ visual-studio-2012 serialization boost


    【解决方案1】:

    别忘了包含

    #include <boost/serialization/serialization.hpp>
    #include <boost/serialization/shared_ptr.hpp>
    

    【讨论】:

    • 即使添加了上述头文件..问题仍然存在
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多