Why do some T.init evaluate to true while others to false?

ArturG via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 27 07:43:47 PDT 2016


On Friday, 27 May 2016 at 09:25:55 UTC, Marc Schütz wrote:
> On Thursday, 26 May 2016 at 16:45:22 UTC, ArturG wrote:
>> im just playing with this template[1] is there anything else i 
>> missed? (if you dont mind)
>> it basically treats any T.init as false and skips the 
>> function/delegate and just returns type.
>>
>> [1] https://dpaste.dzfl.pl/d159d83e3167
>
> If you just want to check whether something is equal to its 
> type's .init value, use the `is` operator, which does a bitwise 
> comparison:
>
>     if(value is typeof(value).init) ...

that still requiers a special case for floating points, arrays 
and optionally empty string literals.




More information about the Digitalmars-d-learn mailing list