A function with variadic template parameters is just a function which takes a set of compile-time known parameters.<div>My goal is to have a non-template function taking variadic parameters.</div><div><br></div><div>long bar(...)</div>
<div>{</div><div>    return foo(...);<br>}</div><div><br></div><div>This is necessary to be able to pass variables to functions without knowing the type of the functions.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Dec 5, 2012 at 7:33 PM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com" target="_blank">doob@me.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 2012-12-05 11:01, Gor Gyolchanyan wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
What's the best (least overhead and most portable and safe) way wrapping<br>
a function into a variadic-parameter function?<br>
<br>
For instance:<br>
<br>
long foo(int i, char c)<br>
{<br>
    /// ...<br>
}<br>
<br>
long bar(...)<br>
{<br>
     return foo(/* ??? */);<br>
}<br>
<br>
This is necessary for losing the parameter types, but still having the<br>
function callable with its expected parameters. I suspect this could be<br>
done using inline assembler and knowledge of the D ABI to achieve<br>
near-zero overhead.<br>
<br>
The wrapper can include dynamic type checking using the automatically<br>
passed _arguments array to ensure type safety.<br>
<br>
This is useful for dynamic dispatching.<br>
</blockquote>
<br></div></div>
It might not be want you need but a variadic template is the easiest solution:<br>
<br>
long bar (Args ...) (Args args)<br>
{<br>
    return foo(args);<br>
}<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
/Jacob Carlborg<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>