Santiago V.
Santiago V.

Reputation: 1118

Forwarding variable arguments in functions in D

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!

Upvotes: 5

Views: 380

Answers (2)

BCS
BCS

Reputation: 78605

I think core.vararg might be of use.

Upvotes: 1

ratchet freak
ratchet freak

Reputation: 48196

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

Upvotes: 7

Related Questions