opCast!bool
simendsjo
simendsjo at gmail.com
Tue Jan 3 08:41:12 PST 2012
I guess this is as designed, but I'll ask anyway.
http://dlang.org/operatoroverloading.html#Cast says an expression is
rewritten to opCast "whenever a bool result is expected".
This is true for
if(e) somethingElse
and e && somethingElse
, but not for other parts.
assert(cast(bool)e == true); // explicit cast works
assert(e == true); // Error: incompatible types for ((s) == (false)):
'S' and 'bool'
is(typeof(e) : bool); // false
More information about the Digitalmars-d-learn
mailing list