title: Specializing class for generic function returning pointer to function
body: <p>I'm trying to specialize a class template declared as such:</p>
  
  <pre><code>template&lt;typename T&gt; class A;
  </code></pre>
  
  <p>for a function returning a function pointer. This needs to be a generic signature for any given arity of function.</p>
  
  <p>So, assuming that I know how C/C++ syntax works, the specialization should look something like this for a function returning some type <code>ResultType</code>:</p>
  
  <pre><code>template&lt;typename ResultType, typename Arg1, typename Arg2&gt;
  A&lt;ResultType(Arg1, Arg2)&gt; {...};
  </code></pre>
  
  <p>And expanding that to having ResultType being a function pointer should look something like this:</p>
  
  <pre><code>template&lt;typename FpResultType, typename FpArg1, typename Arg1, typename Arg2&gt;
  A&lt;(ResultType(*)(FpArg1))(Arg1, Arg2)&gt; {...};
  </code></pre>
  
  <p>This, however, results in an 'invalid template parameter' on GCC 4.6.</p>
  
  <p>As far as I know typedefs are a no-go here. Adding a utility class to create a typedef for me is additionally a no-go, as that moves types from the list of typenames in the template declaration to within another template type and 'hides' them from A's template specialization (resulting in a compile-time error that the typenames declared are not used in the specialization).</p>
  
  <p>I'd rather like to avoid having a long complex chain of enable_ifs and utility structs. But, if that's the only way to do it, meh.</p>