Can't use variadic arguments to functions that use templates

bearophile bearophileHUGS at lycos.com
Sat Jul 20 10:39:57 PDT 2013


JS:

> variadic parameters are suppose to make life easier but it 
> seems those don't work with templates.
>
> template A(int L) { ... }
>
> void foo(T)(string s, T t...)
> {
>    A!(t.length);
>
> }

Try this:


template A(size_t L) {
     enum A = L;
}

void foo(T...)(string s, T t) {
     auto n = A!(t.length);
}

void main() {
     foo("x", 1, 2);
}


Bye,
bearophile


More information about the Digitalmars-d-learn mailing list