opDispatch or equivalent at static context

Ali Çehreli acehreli at yahoo.com
Thu Jan 21 16:56:33 PST 2010


Chris Nicholson-Sauls wrote:

>> Isn't that what opDispatch does now?
>>
>> -Lars
> 
> Not as a static member, to my knowledge.  At the very least, I see no 
> mention of static forwarding in the docs: 
> http://www.digitalmars.com/d/2.0/operatoroverloading.html#Dispatch

The fact that the name of the non-existent function arrives as a 
template parameter indicates that it is static dispatch.

Which made me realize that it can be overloaded:

void opDispatch(string name : "special_member_function_name", T)(T 
parameter)
{
     // special implementation for "special_member_function_name"
}

Ali



More information about the Digitalmars-d mailing list