manifest enum

Sean Kelly sean at f4.ca
Tue Jan 1 15:45:22 PST 2008


John Reimer wrote:
> YDerek Parnell wrote:
> 
>>
>> There is no difference between a group of manifest constants and a single
>> manifest constant.
>>
>>   enum x = 3;
>>   enum y = "four";
>>
>> and
>>
>>   enum {x = 3, y = "four"};
>>
>> are semantically identical.
>>
>> The documenation says this ...
>>
>> "If there is only one member of an anonymous enum, the { } can be 
>> omitted".
>>
> 
> Yep, I read that.
> 
> But it wasn't clear to me that the following statement applied to 
> anonymous enums also:
> 
> "such declarations are not lvalues, meaning their address cannot be taken."
> 
> The fact that both these statements were in a separate section titled 
> "Manifest Constants" made it look like these were treated as an 
> independent entity from "Anonymous Enums", the section just before it.

'enum' is now basically a storage class in addition to an enumeration 
specifier, so you can even do this I believe:

enum:
     a = 1;
     b = 2;


Sean



More information about the Digitalmars-d mailing list