title: Non-type template parameter... that's a template! (C++)
body: <p>I'm basically looking to generate a wrapper for a generic C function without having to manually specify the types. So I have a callback with a fixed prototype but I'm going to need to do some special code in the wrapper based on the type of the wrapped function... So basically I'm thinking about using a static method in a class template to wrap my function to a conforming interface e.g.:</p>
  
  <pre><code>// this is what we want the wrapped function to look like
  typedef void (*callback)(int); 
  void foobar( float x ); // wrappee
  
  // doesn't compile
  template&lt; T (*f)(S) &gt; // non-type template param, it's a function ptr
  struct Wrapper
  {
    static void wrapped(int x)
    {
       // do a bunch of other stuff here
       f(static_cast&lt;S&gt;(x)); // call wrapped function, ignore result
  
    }
  }
  </code></pre>
  
  <p>And then I'd like to do something like: </p>
  
  <pre><code>AddCallback( Wrapper&lt;foobar&gt;::wrapped );
  </code></pre>
  
  <p>However, the problem is that I can't just go ahead and use a "S" in the parameter of the function in the Wrapper template, I have to first list it as a parameter:</p>
  
  <pre><code>template&lt; class T, class S, T (*f)(S) &gt;
  struct Wrapper
  // ...
  </code></pre>
  
  <p>But this means it's a lot more painful to use (<code>Wrapper&lt;void,float,foobar&gt;::wrapped</code>), ideally I'd like to just pass in the function pointer there and have it work out the types of the parameters (and return types) automatically. To be clear, inside the wrapped function I'm going to need to refer to the types of the function pointer (so I do need some equivalent of S or T).</p>
  
  <p>Is there a way of doing this?</p>