我正在尝试将序列化集成到我的代码中。但是,我得到一个“没有命名成员”错误。我正在阅读的书说 std::pair 不需要包含头文件并且不存在。如何修复此错误?我的代码如下所示:
#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;
}