Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'struct std::pair<int, int>' has no member named 'serialize'

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;
}
like image 546
user957121 Avatar asked Apr 21 '13 11:04

user957121


1 Answers

Add #include <boost/serialization/utility.hpp> to enable std::pair serialization.

like image 57
Igor R. Avatar answered Sep 18 '22 13:09

Igor R.