$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] is_virtual_base_of ?
From: Daniel Frey (d.frey_at_[hidden])
Date: 2009-03-08 06:31:22
On 08.03.2009, at 11:02, John Maddock wrote:
>> If not is there a way to make such a thing?
> Can't think of a method off the top of my head, but Boosters are a
clever lot so you never know....!
One can check if the size changes when creating another class:
template< typename D, typename B >
struct is_virtual_base_of
{
struct X : D, virtual B {};
enum { value = sizeof(X)==sizeof(D) };
};
template< typename T >
struct is_virtual_base_of< T, T >
{
enum { value = false };
};
it triggers some warnings with GCC in my experiments when a base class
is *not* virtual, but it seems to detect virtual bases just fine.
Disclaimer: It's a start, nothing more. I have no idea how other
compilers (even other compiler versions of GCC other than 4.3.2) will
react on it, etc.
Regards, Daniel