unary operator overloading syntax
Lutger
lutger.blijdestijn at gmail.com
Sat Jun 12 03:20:14 PDT 2010
Robert M. Münch wrote:
> Hi, why does this work:
>
> void* opUnary(string s)() if (s == "*"){...
>
> but this not:
>
> void* opUnary("*")() {...
>
>
> If the first syntax is the only possible one, can I have several
> opUnary entries per struct/class or do I have to build a big switch
> inside the code section and use "s" to dispatch to correct handler?
>
(string s) is a (template) parameter to opUnary, containing the operator to be matched, so only the latter is valid
syntax. You can have multiple opUnary templates distinguished by constraints, or a switch, or a combination thereof.
More information about the Digitalmars-d
mailing list