pointers to primitive objects are not serializable by default. This is
explained in the document which describes serialization traits. The reason
for this is
a) suppose one place in the program I serialization a pointer to a float.
Then addresses of ALLL the floats in the program would end up being
seriailzed which is probably not what one wants.
The solution is to make a wrapper so the the type has its own class
BOOST_STRONG_TYPEDEF(float, tracked_float)
Then use a tracked_float instead of a normal float where you want to
serialize it through a pointer.
Note that strings and characters are both considered primitive types in this
context - I just used float as an example.
This is the second time this question has come up so I guess we need to
augment the manual and/or include another static assertion in the code.
Good Luck - hope this his helpful
Robert Ramey
"Jeffrey Holle"
At this point, the last compilation problem in applying the boost.serialization library to my application has to do with pointers.
Specifically, its pointers to std::string and char member attributes.
I have other pointer member attributes that compile successfully, but this point to objects that have serialize methods.
I have attempted use of register_type and am including "serialization/string.hpp" in the modules that have pointer to string attributes. These actions were not affective.
As an example of the type of compilation error, when I uncomment the following attribute's archive attempt: char *m_pByPointerPrefix; I get:
/home/jholle/boost_1_32_0/boost/serialization/access.hpp: In static member function `static void boost::serialization::access::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_iarchive, T = char]': /home/jholle/boost_1_32_0/boost/serialization/serialization.hpp:78: instantiated from `void boost::serialization::serialize(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_iarchive, T = char]' /home/jholle/boost_1_32_0/boost/serialization/serialization.hpp:121: instantiated from `void boost::serialization::serialize_adl(Archive&, T&, unsigned int) [with Archive = boost::archive::binary_iarchive, T = char]' /home/jholle/boost_1_32_0/boost/archive/detail/iserializer.hpp:155: instantiated from `void boost::archive::detail::iserializer
::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned int) const [with Archive = boost::archive::binary_iarchive, T = char]' VariableName.cpp:102: instantiated from here /home/jholle/boost_1_32_0/boost/serialization/access.hpp:106: error: request for member `serialize' in `t', which is of non-class type `char' What is the solution to this?