在Boost序列化中,boost_shared指针不会编译.给错误
In Boost serialization,boost_shared pointer does not compile.. give error
我正在尝试使用boost序列化共享指针,但它给出了错误:c:usersallworkhopelibboost_1_55_0boostmplprint.hpp 51 1输入
我甚至尝试了在链接- 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);
别忘了包括
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/shared_ptr.hpp>
相关文章:
- 非类型指针和引用模板参数,以及在编译时如何/为什么解析它们.c++
- 模板方法访问正向声明的类仅在没有此指针的情况下无法编译
- 编译器不会使用 -std=c++11 编译智能指针
- 为什么通过指针编译时不能分配 const 初始化
- std::less是否应该允许在编译时比较不相关的指针?
- 对带有唯一指针的 std::thread 使用类成员函数时出现编译错误
- 是否可以在编译时初始化对象的 C 样式函数指针,以便它调用对象的成员函数?
- 编译包含指向模板函数的指针的初始值设定项列表时,gcc 出错,但 clang 不出错
- C++编译时使用 constexpr 字符数组指针分配静态数组?
- 通过在编译时折叠带有索引的指针来分配 C 数组
- 使用指针编译代码后,.cpp文件将变为随机字符
- 如何在编译时创建具有函数签名的函数指针
- 类数据成员指针的非类型模板参数包无法使用 gcc 编译
- 唯一指向非指针编译错误
- C++成员函数指针编译错误
- 函数指针 - 编译时错误
- 指向函数的指针编译时出错
- 抽象类类型指针编译成功
- 指向回调函数的指针.编译错误
- c++类指针——编译错误