5
votes

I have a function void foo(...) and a function void bar(...) and I want to call bar from foo, in a way that bar receives the same variable argument list than foo.

Is that possible in D?

Thanks!

2

2 Answers

7
votes

if you use templates yes

void foo(A...)(A a){
    bar(a);
}

void bar(B...)(B b){
//...
}

the a gets expanded that compile time to what arguments it was called with

you can also slice[] off some arguments, or you add an argument to the list

1
votes

I think core.vararg might be of use.