Implicit enum conversions are a stupid PITA
BCS
none at anon.com
Thu Mar 25 12:07:32 PDT 2010
Hello Adam,
> On Thu, Mar 25, 2010 at 11:45:11AM -0700, Walter Bright wrote:
>
>> Good point. As I recall, we expended an enormous amount of effort
>> working on template syntax, and I certainly feel that
>>
>> octal!"177"
>>
>> is far better than, say:
>>
>> octal<"177">.value
>>
>> but when I compare it to
>>
>> 0177
>>
> What about O!177?
template O(ulong i)
{
static if(i <= 7) enum O = i;
else
{
static assert(i%10 < 8);
enum O = O!(i/10)*8 + i%10;
}
}
OTOH you cant do:
O!17777777_7777777_7777777;
as that overflows as a base 10 number but not as a octal number.
--
... <IXOYE><
More information about the Digitalmars-d
mailing list