Help with serializating an abstract object
I'm running into trouble handling an abstract object in my attempt to apply boost.serialization to my application. Since it doesn't have state, initially I didn't add serialize methods to this class, and got compilization errors for want of these methods. Next, I added noop methods, and got errors because the serialization package attempted to construct an abstract class. I see there is an is_abstract template, but don't know how to employ it. Can somebody give me some pointers? Note that I've choosen to implement non-templated serialize methods, using a forwared reference of the desired archive classes. Should this template be in the definition file, or implementation file (inside or outside the serialize method(s))?
look in the docs under
Reference/ ClassSerialization/ Class Serializaton/Traits/Abstract
for an abstract class T
ar << T, ar >> T, ar & T will fail at compilation - as they must
ar << * T, ar >> * T, ar & * T will function correctly but T should
correspond to an instance of a derived type.
use BOOST_IS_ABSTRACT to indicate that a class is abstract and should only
be serialized through its most derived type.
Robert Ramey
Robert Ramey
"Jeffrey Holle"
I'm running into trouble handling an abstract object in my attempt to apply boost.serialization to my application.
Since it doesn't have state, initially I didn't add serialize methods to this class, and got compilization errors for want of these methods.
Next, I added noop methods, and got errors because the serialization package attempted to construct an abstract class.
I see there is an is_abstract template, but don't know how to employ it.
Can somebody give me some pointers?
Note that I've choosen to implement non-templated serialize methods, using a forwared reference of the desired archive classes.
Should this template be in the definition file, or implementation file (inside or outside the serialize method(s))?
participants (2)
-
Jeffrey Holle
-
Robert Ramey