|
Boost : |
From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-30 10:40:44
>From: "John Maddock" <jm_at_[hidden]>
> >This is tested on Comeau 4.3, Intel C++ 6/7 and g++ 3.2.
>
> Except it *doesn't work* !
>
> The problem is that your static assertion don't test anything, changing
to:
>
> //typedef char TestA[is_base_and_derived<B, D>::result]; // Multiple bases
> (error on g++)
> typedef char TestB[is_base_and_derived<B1,D>::result ? 1 : -1];
> //typedef char TestC[is_base_and_derived<B2,D>::result]; // Private base
> (error on g++)
> typedef char TestD[!is_base_and_derived<int,D>::result ? 1 : -1];
> typedef char TestE[!is_base_and_derived<B, B>::result ? 1 : -1];
> typedef char TestF[is_base_and_derived<B,DV>::result ? 1 : -1]; // Virtual
> base
>
> and both Borland and gcc 3.21 give errors on cases 2 and 6
Well, this means that there are other problems in these compilers. The
following _should_ give an error:
typedef char Test[0];
and indeed it does on the EDG compilers.
Well, then it turns out that even this version doesn't work correctly on g++
and Borland, and it doesn't give an error, either, for the above cases.
Using BOOST_STATIC_ASSERT, this would have been detected.
There's no need to shout. :) The test code should work on a conforming
compiler.
By the way, those "static asserts" were "inherited" from Rani's example
code, with a couple of additions. I guess this is a good reason to use a
portable static assert, like the Boost one.
Regards,
Terje
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk