c++ - Serializing struct containing char* -
i'm getting error serializing char* string error c2228: left of '.serialize' must have class/struct/union
use std::string , const char* it. require char* string.
the error message says all, there's no support in boost serialization serialize pointers primitive types.
you can in store code:
int len = strlen(string) + 1; ar & len; ar & boost::serialization::make_binary_object(string, len);
and in load code:
int len; ar & len; string = new char[len]; //don't forget deallocate old string ar & boost::serialization::make_binary_object(string, len);
Comments
Post a Comment