Can anyone tell me what is wrong with the following code:
#include <iomanip>
#include <iostream>
#include <fstream>
#include <string>
#include
#include
#include
#include
#include
#include
#include
*class* ResData{
*friend* *class* boost::serialization::access;
*friend* std::ostream&
*operator*<<(std::ostream &os, const ResData& rD);
*private*:
std::string resName;
int seqNum;
int insNum;
float sAS;
*public*:
ResData();
ResData(std::string, int, int);
std::string getResName() const
{ *return* resName;}
int getSeqNum() const
{ *return* seqNum;}
int getInsNum() const
{ *return* insNum;}
float getSAS() const
{ *return* sAS;}
void setSAS(float sASP)
{ sAS = sASP;}
*template*<*class* Archive>
void serialize(Archive&, const unsigned int);
};
std::ostream&
*operator*<<(std::ostream& os, const ResData& rD){
*return* os << rD.getResName() << rD.getSeqNum() << rD.getInsNum() << rD.getSAS();
}
int main(){
std::ofstream oFSBS("/home/Seb/Code/testData/results.dat");
boost::archive::text_oarchive oA(oFSBS);
ResData temp("TEST", 1, 1);
temp.setSAS(5555);
oA << temp;
oFSBS.close();
}
I get the following error upon compilation:
/usr/include/boost/archive/detail/oserializer.hpp: In function ‘void
boost::archive::save(Archive&, T&) [with Archive =
boost::archive::text_oarchive, T = ResData]’:
/usr/include/boost/archive/basic_text_oarchive.hpp:78: instantiated from
‘void boost::archive::basic_text_oarchive<Archive>::save_override(T&,
int) [with T = ResData, Archive = boost::archive::text_oarchive]’
/usr/include/boost/archive/detail/interface_oarchive.hpp:85:
instantiated from ‘Archive&
boost::archive::detail::interface_oarchive<Archive>::operator<<(T&)
[with T = ResData, Archive = boost::archive::text_oarchive]’
test.cpp:54: instantiated from here
/usr/include/boost/archive/detail/oserializer.hpp:566: error: invalid
application of ‘sizeof’ to incomplete type
‘boost::STATIC_ASSERTION_FAILURE