1
所以......升壓系列化stringstream的錯誤
每當我運行以下命令:
#inlcude <iostream>
#include <sstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
using namespace std;
class gps_position
{
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & degrees;
ar & minutes;
ar & seconds;
}
int degrees;
int minutes;
float seconds;
public:
gps_position(){};
gps_position(int d, int m, float s) :
degrees(d), minutes(m), seconds(s)
{}
};
int main() {
stringstream ss1;
const gps_position g(35, 59, 24.567f);
{
boost::archive::text_oarchive oa(ss1);
oa << g;
}
gps_position newg;
{
stringstream ss2;
boost::archive::text_iarchive ia(ss2);
ia >> newg;
}
return 0;
}
我得到以下錯誤:
terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): output stream error
Aborted
所以......這令我感到困惑..任何幫助都會很棒!
謝謝!