Enum that can be 0 or null

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 7 12:18:10 PDT 2016


On 06/07/2016 08:50 PM, ParticlePeter wrote:
> On Tuesday, 7 June 2016 at 14:31:40 UTC, Alex Parrill wrote:
>> I don't think opCast gets called for implicit conversions; it only
>> gets called for explicit casts. I'll test it later.
>
> It does for type bool, but I fear that's the only exception.

No, opCast can't be used for implicit conversions to bool.

I guess you're thinking of the `if(foo) {...}` case. That's considered 
an explicit conversion. `bool b = foo;` still won't work.


More information about the Digitalmars-d-learn mailing list