Reputation: 502
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
Upvotes: 2
Views: 2087
Reputation: 827
You need a combination of shared_ptr.hpp and boost version 1.56
Upvotes: 0
Reputation: 393134
You probably forgot to include
#include <boost/serialization/shared_ptr.hpp>
Upvotes: 5