I'm trying to integrate serialization into my code. However, I get the a 'has no member named' error. The book I'm reading says that std::pair doesn't need a header file to include and there does not exist . How to fix this error? My code look like this:
#include <iostream>
//ofstream/ifstream
#include <fstream>
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
//stringstream
#include <sstream>
//
#include <boost/serialization/complex.hpp>
#include <boost/serialization/bitset.hpp>
//#include <boost/serialization/
//BOOST_BINARY
#include <boost/utility/binary.hpp>
using namespace std;
int main()
{
complex<double> c(1,0);
bitset<3> b(BOOST_BINARY(101));
pair<int,int> p(1,2);
string s;
std::stringstream ss(s);
boost::archive::text_oarchive oa(ss);
oa<<c<<b<<p;
{
complex<double> c;
bitset<3> b;
pair<int,int> p;
boost::archive::text_iarchive ia(ss);
ia>>c>>b>>p;
}
return 0;
}
Add #include <boost/serialization/utility.hpp>
to enable std::pair
serialization.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With