problem with serialization of pure virtual

Hello I read the documention and some prior postings to related topics. But none of the proposed solutions seems to work for me. My problem: I have an abstarct base class(with pure vitual function) and several derived from that. All are written in the same source/header -file. I want to serialize an object via a pointer to the base-class. When i use "ar.register<derived>();" in the template of the base-class to register the derived classes, i get a syntax error. When i export them with "BOOST_CLASS_EXPORT(derived);" or BOOST_CLASS_EXPORT_GUID(derived,"derived") it doesn't work (i think because they are all in the same file). I'm also using "BOOST_IS_ABSTRACT(base);" When i comment "oa << object;" ervything compiles fine. Uncommented i get a: boost/archive/detail/oserializer.hpp:567: error: incomplete type ` boost::STATIC_ASSERTION_FAILURE<false>' does not have member `value' error... So is there a solution (without seperating the derived classes into different files) for this problem?

Tobias Combe wrote:
Hello
I read the documention and some prior postings to related topics. But none of the proposed solutions seems to work for me.
My problem:
I have an abstarct base class(with pure vitual function) and several derived from that. All are written in the same source/header -file. I want to serialize an object via a pointer to the base-class. When i use "ar.register<derived>();" in the template of the base-class to register the derived classes, i get a syntax error.
what syntax error do you get? conforming compilers can't compile
ar.register<derived>()
but need ar.template register<derived>() (or something like that). To
avoid have to remember this I use the following idiot proof syntax:
ar.register(static_cast
When i export them with "BOOST_CLASS_EXPORT(derived);" or BOOST_CLASS_EXPORT_GUID(derived,"derived") it doesn't work (i think because they are all in the same file).
In order for BOOST_CLASS_EXPORT to function - it has to follow the the boost/archive/... declarations.
I'm also using "BOOST_IS_ABSTRACT(base);"
and...?
When i comment "oa << object;" ervything compiles fine. Uncommented i get a: boost/archive/detail/oserializer.hpp:567: error: incomplete type ` boost::STATIC_ASSERTION_FAILURE<false>' does not have member `value' error...
This is an entirely separate issue. Check the comments at oserializer.hpp 567 and the documentation rationale for information on this topic. Robert Ramey
participants (2)
-
Robert Ramey
-
Tobias Combe