Evaluate a metafunction taking a function parameter, DRY and without using a macro?
<p>I have a template which takes a function of some varying signature as an argument, and produces a related function of a simple signature. The details aren't terribly important, it's some kind of delegate. It looks roughly like this.</p>

<pre><code>struct foo;

using desired_signature_t = int(*)(foo*);

template &lt;typename F, F f&gt;
struct make_delegate;

template &lt;typename... Args, int(*target_func)(foo*, Args...)&gt;
struct make_delegate&lt;int(*)(foo*, Args...), target_func&gt; {
   static int delegate(foo *) { ... }
};
</code></pre>

<p>To use it, what I currently do is:</p>

<pre><code>#define MAKE_DELEGATE(f) &amp;make_delegate&lt;decltype(f), (f)&gt;::delegate

int bar(foo *, int, float, double);

desired_signature_t delegated_bar = MAKE_DELEGATE(&amp;bar);
</code></pre>

<p>I use a macro because, I don't like having to type the argument twice, once for decltype and once for the actual function pointer.</p>

<p>Is there a way to do this without typing it twice and also without using a macro? The issue is that the type of a non-type template parameter cannot be deduced, and I couldn't find a way to deduce those types first in an earlier template. I thought about trying to construct a literal object with a template constructor as a helper, but I'm not sure if that's helpful -- I still can't use the parameter to the ctor as a template parameter inside the ctor, and once I'm out of the ctor I don't know the function type anymore.</p>