This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: I can not compile code from <<modern c++ design>>
Matthias Oltmanns <Mathias dot Oltmanns dot Oltmanns at sysde dot eads dot net> writes:
> Am Mon, 2003-04-07 um 11.24 schrieb Di Yang:
>> Hi,
>>
>> public:
>> enum { exists = sizeof(Test(MakeT())) == sizeof(Small) };
>
> Hi,
>
> this seems to be not valid C++ code because the calls to the
> static members 'Test' and 'MakeT' are not const expressions at compile
> time.
It is valid C++. Note that we are applying 'sizeof' to the result
*type* of the function.
> For assignments to enum literals there are only integer expressions
> allowed which are evaluated at compile time.
Right. And 'sizeof' is always a compile-time thing.
To the OP: There is a GCC compatible implementation of Loki on
www.moderncppdesign.com
--
Oscar