Alias Arguments & Expressions
Xinok
xnknet at gmail.com
Tue Jan 16 12:33:07 PST 2007
> Second, I don't really comprehend what you are trying to do with the template above... it
> would just be:
> # template mul (a, b) { const mul = a * b; }
> #
> # void main () {
> # writefln(mul!(15, 30));
> # }
a and b are typenames, not variables. You can't use aliases either since they don't accept variables:
template mul(alias a, alias b)
The only thing that will work is a tuple:
template mul(V...){ const mul = V[0] * V[1]; }
And for a complex expression, that isn't very pleasing to the eye.
You were right about not needing 'auto'. I didn't think D allowed that though.
More information about the Digitalmars-d
mailing list