PhobosWatch: manifest => enum

James Dennett jdennett at acm.org
Sat Dec 29 19:00:01 PST 2007


Walter Bright wrote:
> Bruce Adams wrote:
>> Personally I always name my types but there may be those that don't.
>> Is this currently illegal then?
>>
>> class Colour
>> {
>> private:
>>   // private helper type defining colour state variable
>>   // using an anonymous enum.
>>   enum { red, green, blue } colour;
>> };
> 
> Yes, it is illegal.
> 
>> Why opAdd and not opIncrement?
> 
> opIncrement is redundant, as it's a subset of opAdd.

Except if you care about efficiency, in which case you might
well have types which admit an efficient (constant time)
increment but not a constant-time addition in general.

(Contiguous enumerated types should not have that issue,
however, nor should any type which has an underlying
integral representation.)

-- James



More information about the Digitalmars-d mailing list