I have a class named A which I want to serialize it's object in another class named B . but I keep getting this error:
error: ‘class std::shared_ptr<A>’ has no member named ‘serialize’
class A is:
class A
{
public:
typedef shared_ptr<A> Ptr;
string name;
Predicate(const string &name = ""):name(name)
{}
private:
template<typename Archive>
void serialize(Archive& archive, const unsigned int v)
{
archive & name;
}
friend class B;
friend class boost::serialization::access;
}
And class B :
class B
{
public:
typedef unordered_set<A::Ptr,
APtrKeyHash,
APtrKeyEq> A_set_t;
A_set_t test;
private:
template<typename Archive>
void serialize(Archive& archive, const unsigned int v)
{
archive & test;
}
friend class boost::serialization::access;
}
note that by shared_ptr here I mean std::shared_ptr, not boost::shared_ptr. in fact I used this line: using namespace std; before my A class
您可能忘了包括
#include <boost/serialization/shared_ptr.hpp>
您需要shared_ptr.hpp和boost版本1.56的组合
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.