Operator overloading, structs

bearophile bearophileHUGS at lycos.com
Thu Jun 4 00:32:40 PDT 2009


Yigal Chripun:
> that is an implicit cast.
> what I'm saying is that:
> 
>   int a = .. ;
>   if (a) { .. }
> 
> this should be a compiler error IMO.

I think the opposite is good: that empty collections are "false", so the following ones print X:

int[]  a;
if (!a) printf("X");
Set!(int) s;
if (!s) printf("X");
int[string] aa;
if (!aa) printf("X");

Bye,
bearophile



More information about the Digitalmars-d mailing list