Operator overloading, structs

Max Samukha outer at space.com
Fri Jun 5 00:30:15 PDT 2009


On Thu, 04 Jun 2009 13:10:58 -0500, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:

>Max Samukha wrote:
>> On Thu, 04 Jun 2009 10:41:31 -0500, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>> 
>> 
>>> You are mistakenly presupposing that if() takes a bool. In reality if() 
>>> accepts a bool, an integral, a floating-point type, a pointer, an array, 
>>> or a class reference.
>> 
>> or delegate
>
>I was sure I forgot something... and hash too. Anything that can be 
>compared against 0 or null.
>
>Andrei
Yeah. If anybody doesn't know, it works like this:
IfStatement::semantic checks Expression::checkToBoolean, which for
delete, assignment etc issues an error and for other expressions calls
Type::checkBoolean, which for most types except arrays, class
references etc. calls isscalar().   



More information about the Digitalmars-d mailing list