【发布时间】:2014-03-26 11:13:31
【问题描述】:
我在使用 boost 序列化共享指针时再次遇到问题,下面是代码:
//内容.hpp文件
#include <boost/serialization/string.hpp>
#include <boost\serialization\shared_ptr.hpp>
#include <boost/serialization/list.hpp>
struct Content
{
std::string type;
boost::shared_ptr<Content> mycontent; // mycontent is of type Content
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int version)
{
ar & id;
ar & name;
ar & mycontent;
}
public:
Content(void);
Content(const parameter_strings & parms);
~Content(void);
};
// 内容.cpp 文件
Content::Content(void)
{
}
Content::~Content(void)
{
}
Content::Content(const parameter_strings & parms)
{
// implementation part
}
如果我注释行“-- boost::shared_ptr mycontent;--”它编译没有错误,但我需要使用 shared_ptr,因此它给出错误:
它给出错误:错误 C4308:负整数常量转换为无符号类型
我也包含了所有必需的头文件,但问题仍然存在。
【问题讨论】:
标签: c++ visual-studio-2012 serialization boost