unary operator overloading syntax

Lutger lutger.blijdestijn at gmail.com
Sat Jun 12 04:03:23 PDT 2010


Robert M. Münch wrote:

> On 2010-06-12 12:20:14 +0200, Lutger said:
> 
>> (string s) is a (template) parameter to opUnary, containing the
>> operator to be matched, so only the latter is valid syntax.
> 
> You mean, "only the first syntax is valid" because the second version
> (latter) doesn't compile for me.
> 

Yes, sorry, that was a mistake. Note you can also do things like this with constraints:


void* opUnary(string s)() 
    if (s == "*") 
{ ... }


void* opUnary(string s)() 
    if (s=="++" || s=="--" || s=="+" || s=="-") 
{ ... }




More information about the Digitalmars-d mailing list