How to delegate varargs

Tomas Lindquist Olsen tomas at famolsen.dk
Tue Nov 20 12:29:28 PST 2007


Frank Benoit wrote:
> How can I delegate the variadic argument list to another variadic
> argument function?
> 
> e.g.
> void myWritef( char[] frm, ... ){
>   writefln( frm, ??? );
> }
> 
> And how can I add or remove arguments to these varargs?

You have to write a "wrapper" function that explicitly takes the hidden 
arguments. In the case of writefln, phobos provides OutputStream.writefx.

To modify the hidden arguments, you would have to know the size of the 
buffer _argptr points to. I don't see how this is possible with DMD :/



More information about the Digitalmars-d mailing list