How to unpack template parameters,Or how to forward parameters?
zjh
fqbqrr at 163.com
Fri May 6 00:41:18 UTC 2022
Hello everyone,I have following function:
```d
import core.stdc.stdio;
void f(int i,int j){
printf("%i,%i",i,j);
}
```
I want to forward `int[N]` to `(int i,int j)` etc. How can I
write a forwarding function?
```d
void ff(alias g,int...I)(int[2]k){
g(k[I]);
}//How to unpack template variable parameters?
void f(int[2]k){
ff!(f,0,1)(k);//how to forward?
}
```
main function:
```d
extern(C):void main()
{
int[2] a=[2,4];
f(a);//calling like this
}
```
More information about the Digitalmars-d-learn
mailing list