"Gennaro Prota" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thu, 30 Jan 2003 12:38:36 -0000, "John Maddock" > <[EMAIL PROTECTED]> wrote: > > >Except it *doesn't work* ! > > > > John, unfortunately I have to turn off my computer now. I had just > hacked up a version that seems to work with gcc, but I don't want to > post it before a better testing. I'll let you know in the morning.
Maybe you had the following variation on Terje's code in mind. The following worked with GCC3.1/2, VC6/7/7.1 and Comeau 4.3.0.1: typedef char (&yes)[1]; typedef char (&no) [2]; template <typename B, typename D> struct helper { template <typename T> static yes check(D const volatile *, T); static no check(B const volatile *, int); }; template<typename B, typename D> struct is_base_and_derived { struct Host { operator B const volatile *() const; operator D const volatile *(); }; enum { result = sizeof(helper<B,D>::check(Host(), 0)) == sizeof(yes) }; }; struct B {}; struct B1 : B {}; struct B2 : B {}; struct D : B1, private B2 {}; struct BV1 : virtual B {}; struct BV2 : virtual B {}; struct DV : BV1, BV2 {}; typedef char TestA[is_base_and_derived<B, D>::result ? 1 : -1]; // Multiple bases typedef char TestB[is_base_and_derived<B1,D>::result ? 1 : -1]; typedef char TestC[is_base_and_derived<B2,D>::result ? 1 : -1]; // Private base typedef char TestD[!is_base_and_derived<int,D>::result ? 1 : -1]; typedef char TestF[is_base_and_derived<B,DV>::result ? 1 : -1]; // Virtual base // VC6/7 BUG. // typedef char Test[!is_base_and_derived<D,D>::result ? 1 : -1]; Cheers, Rani _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost