Reputation: 10507
So...
Whenever I run the following:
#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;
}
I get the following error:
terminate called after throwing an instance of 'boost::archive::archive_exception'
what(): output stream error
Aborted
So... This baffles me... any help would be GREAT!
Thanks!
Upvotes: 1
Views: 2729
Reputation: 62975
In main
you populate ss1
, then create a new std::stringstream
called ss2
and try to read from that. How would you expect this to work? It's clear that ss2
contains no data.
Upvotes: 4