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!
Explanation: Every actual argument list must be known at compile time.
The va_list may be passed as an argument to another function, but calling va_arg() within that function causes the va_list to have an indeterminate value in the calling function. As a result, attempting to read variable arguments without reinitializing the va_list can have unexpected behavior.
The C standard mandates that the only place the identifier __VA_ARGS__ can appear is in the replacement list of a variadic macro. It may not be used as a macro name, macro argument name, or within a different type of macro. It may also be forbidden in open text; the standard is ambiguous.
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
I think core.vararg might be of use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With