How to cast from double(*)(void) to a function pointer with given number of parameter?
<p>I have a function pointer with with type <code>double(*)(void)</code> and I want to  cast it to a function with given number parameter.</p>

<pre><code>// already have function my_func with type double(*)(void)
int para_num;
para_num = get_fun_para_num(); // para_num can be 1 or 2

if para_num == 1
    cout &lt;&lt; static_cast&lt;double (*)(double)&gt;(my_func)(5.0) &lt;&lt; endl;
else
    cout &lt;&lt; static_cast&lt;double (*)(double, double)&gt;(my_func)(5.0, 3.1) &lt;&lt; endl;
</code></pre>

<p>I can ensure that the cast is correct, is any way to do the cast without if-else?</p>