I can not compile code from <<modern c++ design>>
Oscar Fuentes
ofv@wanadoo.es
Mon Apr 7 19:49:00 GMT 2003
Matthias Oltmanns <Mathias.Oltmanns.Oltmanns@sysde.eads.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
More information about the Gcc-help
mailing list