Implicit conversion to bool, and other conversions.

Carl Sturtivant sturtivant at gmail.com
Fri Aug 16 14:18:51 PDT 2013


The operator overloading page in the Language Reference and the 
operator overloading discussion in TDLP say different things about
   T opCast(bool)() if(is(T==bool))
and experimentally it seems that in any context where a bool is 
expected and x occurs (where x is a struct with such an opCast 
defined) then x will be rewritten as its conversion to bool using 
that opCast.

Please confirm that the above is generally true or tell me the 
exact rules.

Are there any other implicit conversions possible in D (apart 
from int to long, int to double and so forth)?



More information about the Digitalmars-d-learn mailing list