|
Boost : |
Subject: Re: [boost] bug in type_traits/is_virtual_base_of ??
From: Daniel Larimer (dlarimer_at_[hidden])
Date: 2010-02-11 16:00:09
Here is my fix that attempts to account for the potential case of the compiler padding the structure size when the derived class adds members and/or virtual functions. I made the destructor of X and Y virtual and added an extra data-field that causes both X and Y to experience the same shift in padding and thus the only remaining difference is the virtual Base vs non-virtual Base.
What do you think? Any potential problems / side effects?
template<typename Base, typename Derived>
struct is_virtual_base_of_impl<Base, Derived, mpl::true_>
{
struct X : Derived, virtual Base
{
X();
X(const X&);
X& operator=(const X&);
virtual ~X();
char x;
};
struct Y : Derived
{
Y();
Y(const Y&);
Y& operator=(const Y&);
virtual ~Y();
char x;
};
BOOST_STATIC_CONSTANT(bool, value = (sizeof(X)==sizeof(Y)));
};
On Feb 11, 2010, at 12:59 PM, John Maddock wrote:
>> cast the bool to an int, still does not work. It works for most cases, for example this works:
>>
>> struct C : public A, public B
>> {
>> virtual test(); //
>> }
>>
>> struct C : public A, public B
>> {
>> virtual test();
>> float parameter; // DOESN"T WORK ANY MORE
>> };
>>
>
> Which specific compiler version? I need something that I can reproduce here... John.
>
> _______________________________________________
> 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