|
Boost Users : |
Subject: Re: [Boost-users] [serialize] using virtual inheritance causes compiler error
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2016-10-27 18:35:16
On 28/10/2016 00:17, Douwe Gelling wrote:
> c) It fails to compile on both apple LLVM 8.0.0 on osx, and on gcc 4.9
> on ubuntu 12.04
It compiles in VS2013...
> That makes the example compile, but doesn't tell me how to serialize an
> object with diamond inheritance, where a pure virtual method from the
> virtual base class is implemented by one of the classes in the middle.
On occasion with diamond inheritance it can help to explicitly instruct
the compiler which "path" to take by further overriding the method in
the class that rejoins the diamond. It's possible this may help with
your issue as well.
eg:
struct A
{
virtual void act() = 0;
};
struct B1 : public virtual A
{
};
struct B2 : public virtual A
{
virtual void act() override { ... }
};
struct C : public B1, public B2
{
// explicitly delegate to one of the bases
virtual void act() override { B2::act(); }
};
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net