Subject: [Serialization] Why is it not possible to serialize this structure through a pointer?

Hello,
I have the following struct:
struct CUBE_INFO {
friend class boost::serialization::access;
long cube;
std::string ncube;
UINT number_dimensions;
DIMENSION_LIST dimensions;
long double number_cells;
long double number_filled_cells;
enum STATUS { UNLOADED = 0, LOADED, CHANGED }
status;
enum TYPE { NORMAL = 0, SYSTEM, ATTRIBUTE }
type;
friend std::istream& operator>>( std::istream& in, CUBE_INFO&
cubeInfo );
friend std::ostream& operator<<( std::ostream& out, const
CUBE_INFO& cubeInfo );
private:
template<class Archive>
void serialize( Archive &ar, const unsigned int version ) {
ar & cube;
ar & dimensions;
ar & ncube;
ar & number_cells;
ar & number_dimensions;
ar & number_filled_cells;
ar & status;
ar & type;
}
};
here, DIMENSION_LIST is an STL-vector of longs. I am including
#include
f:\lib\x32\include\boost\archive\detail\oserializer.hpp(567) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1> f:\lib\x32\include\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save
(Archive &,T &)' being compiled 1> with 1> [ 1> Archive=boost::archive::text_oarchive, 1> T=jedox::palo::CUBE_INFO * 1> ]
regards, Oliver

"Oliver Kania"
f:\lib\x32\include\boost\archive\detail\oserializer.hpp(567) : error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE<x>' 1> with 1> [ 1> x=false 1> ] 1> f:\lib\x32\include\boost\archive\basic_text_oarchive.hpp(78) : see reference to function template instantiation 'void boost::archive::save
(Archive &,T &)' being compiled 1> with 1> [ 1> Archive=boost::archive::text_oarchive, 1> T=jedox::palo::CUBE_INFO * 1> ]
regards, Oliver ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Oliver Kania-3 wrote:
int main(int argc, char* argv[]) { //string filename("SerializeTest"); CUBE_INFO* c = new CUBE_INFO(); std::ofstream ofs("filename"); //std::ofstream ofs("filename" ); // save data to archive { boost::archive::text_oarchive oa( ofs ); // write class instance to archive oa << ( c ); // archive and stream closed when destructors are called } return 0; }
Hello, I've been playing with this all day and I was confused about this very same problem. Try serializing a const pointer. This sort of thing worked for me: int main(int argc, char* argv[]) { //string filename("SerializeTest"); CUBE_INFO* c = new CUBE_INFO(); std::ofstream ofs("filename"); //std::ofstream ofs("filename" ); // save data to archive { boost::archive::text_oarchive oa( ofs ); // write class instance to archive const CUBE_INFO* to_serialize = c; oa << ( *to_serialize ); // archive and stream closed when destructors are called } return 0; } I'm not sure why yet, I'm looking into it right now. Hopefully that will help though! Jeshua Bratman -- View this message in context: http://www.nabble.com/Subject%3A--Serialization--Why-is-it-not-possible-to-s... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (3)
-
Jeshua Bratman
-
Oliver Kania
-
Robert Ramey