On 10/26/16 8:45 AM, Douwe Gelling wrote:
Hi all,
When trying to serialize a class with a virtual base class, I'm getting compilation errors. It seems to be part of a bug in type_traits, but I'm wondering if anyone knows a workaround for making it work anyhow.
ultimately, the error boils down to "error: virtual function 'A::foo' has more than one final overrider in 'boost_type_traits_internal_struct_X'", using the code listing below.. It's simplified as much as possible, but obviously I need virtual inheritance due to using diamond inheritance.
#include
#include #include #include struct A { virtual ~A(){}; virtual void foo() = 0; template <class Archive> void serialize(Archive& ar, const unsigned int version) { } };
struct B : public virtual A { virtual void foo() { } template <class Archive> void serialize(Archive& ar, const unsigned int version) { ar& boost::serialization::base_object<A>(*this); } };
struct C : public B { template <class Archive> void serialize(Archive& ar, const unsigned int version) { ar& boost::serialization::base_object<B>(*this); } };
BOOST_CLASS_EXPORT(C);
int main() { C c; return 0; }
Just some quick observations: a) there is a example/test for diamond inheritance in the test suite b) I don't see diamond inhertance in your example. c) I might be helpful to indicate the compiler d) Your not actually doing an serialization so I doubt you need "export" I would keep cutting down the example until it starts to compile. I'm very doubtful that this has anything to do with serialization or diamond inheritance Robert Ramey