[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: macro for enum operations
From:       Ravikiran Rajagopal <ravi () ee ! eng ! ohio-state ! edu>
Date:       2003-09-10 20:20:32
[Download RAW message or body]

On Wednesday 10 September 2003 08:04 am, Guillaume Laurent wrote:
> On Wednesday 10 September 2003 13:15, Lubos Lunak wrote:
> >  Looks like a good idea, even though creating enum values that are not
> > defined in the enum feels a bit scary, as enum is usually seen as 'one
> > value from a set',
>
> Actually an enum can have any value which can be represented by the number
> of bits of its largest defined value. So the boolean operators are
> perfectly legal.

In C++, enums have sizes that are not necessarily the same as those of ints of 
any form. If I understand the standard right (correct me if I am wrong), the 
size can actually be larger than that of longs. So Simon's patch is not 
guaranteed to be safe in all corner cases. I know this sounds like one of the 
language lawyers on comp.lang.c++.moderated :-)

Please see Dirk's recent commits regarding implicit conversion of enums to 
ints and the problems with gcc 3.4. I am particularly concerned about the "~" 
operator because the return value needs to be converted to EnumType again and 
I wonder whether truncation would cause problems with 1s complement vs 2s 
complement.

Apologies if this OT for this list.

Regards,
Ravi
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic