Boost logo

Boost :

Subject: Re: [boost] is_virtual_base_of ?
From: Robert Ramey (ramey_at_[hidden])
Date: 2009-03-09 20:49:07


I have checked in a boostification/typetraitification of this idea. It can
be found in boost/serialization/is_virtual_base_of.hpp

I have tested it as used in the serialization library with MSVC compilers
and gcc.

With gcc it doesn't indeed create an annoying warning.

I would like to see the type_trait gurus to:

a) look at this
b) see if this gcc warning can be suppressed
c) if its OK move it to the type_traits library and out of the serialization
librar
d) maybe add a separate test.
e) and promote to the next release branch since I prefer to run my local
tests
against the next release branch.

Thank you very much.

Robert Ramey

Daniel Frey wrote:
> 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
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk