Static operator overloads are possible why?

Sean Kelly sean at f4.ca
Fri Jun 29 16:15:14 PDT 2007


Giles Bathgate wrote:
> 
> So how is that in anyway usefull? we have no reference to t, within our operator overload call. 
> (In the first example the reference to t could have been referenced by this)
> 
> So my question; 'should static operator overloads even be allowed?'
> and if they were to be allowed should they not have two arguments?

Personally, I find the existing static operator overloads to be a useful 
tool for various (rarely used, I admit) syntactic tricks.  Aside from 
static opCall being the only means of providing a struct ctor at the 
moment, such things also allow certain types of code to be refactored in 
a fairly efficient manner.  Consider expression templates, for example. 
  Being able to operate directly on types can help to reduce the need 
for placeholder structs in some cases.


Sean



More information about the Digitalmars-d mailing list